Skip to main content
  1. My Blog posts/

Our content, our rules

·865 words·5 mins·
tech floss
Víctor (Bit-Man) Rodríguez
Author
Víctor (Bit-Man) Rodríguez
Algorithm Junkie, Data Structures lover, Open Source enthusiast

Giving the news about some social network dramatic changes on API pricing or changing original direction and in many cases no respecting our content freedom I’ve decided to offer all my posts through my site. Hi Reddit and, ehem, Twitter, I’m talking to you! 👋

It comes with a price and is that had to maintain my own site. Anyway I am currently doing it through Gitlab, Hugo and Blowfish. Also have to take all my messages in every social network like Twitter, Reddit, you-name-it and convert them to a format that can be used in my site. That’s why I decided to make our content our rules tool to convert between social network messages and hosted sites formats

Let me explain then what decisions I made and how they translate to the tech stack that supports it, and if it fits your needs and way to do things! Otherwise you can reach me through my multiple social networks or project issues and code collaboration

Wide end user adoption #

Sometimes these kind of tools starts as a hobby project that requires some tech wizardy degree or runtime to be installed, which converts them into niche players and difficults its massive adoption or even its usage. Sometimes needs to run some shell or console commands to do the magic. I wanted to avoid these which impacts in :

  • Delivery : precompiled binaries ready to download
  • UI: neat and simple graphical interface
  • Documentation: simple instructions, all in one place

Broad audience #

Meaning not only easier to use by the end user but also for tech saavy or even those willing to use it for other non intended purposes. Also if you are more in the tech side, like me 😄, is nice to have some way to fix, adapt or enhance some good idea. These translates into

  • Open standards : every time you use standards means other can connect/interact in a different way and with different tools and purposes
  • Free source code : anyone can contribute and everyone contributions still maintains open
  • Building process : repetable, esier to setup and straightforward use
  • No licenses: to use the programming language, artifact builds or any activity required to produce binaries to be run
  • Code : use widely known and established techniques, practices and concepts for software development

Let me do some experiments here #

I must admit I’m a bit biased towards Kotlin and JVM but I was willing to give GraalVM and native image generation a try, not only for me but for a broader public. Also with JavaScript that I’m not very skilled but want to learn a bit more

Also diving into Lean Startup and trying to apply some tools and principles

The tech stack #

Given the previous decisions let me list the tech stack :

The construction method #

The decisions I made are not only reflected in the tech stack but in the software construcion too. Let me explain.

For once TDD helps to maintain a code fearless, meaning it works for the purpose it was built and we can prove it. When the red, green, refactor cycle ends, and with enough practice, the code quality increases (no fear, it works). Interaction Driven Desing ( IDD) helps to extend TDD to the whole system by modelling behaviour according to the external usage of the system. The common point with TDD is that each class is modelled according to its usage: you begin writing tests and thus you start creating the interface/methods of each class before its implementation

Because coding is not only make the CPU perform what we intend it to do but also comunicate to the next person who needs to understand it (may be the future me) Clean Code comes to the rescue. No code comments, just read the code and it will tell what and how it does the work, the CPU will execute it anyway 😄. And because communication is king don’t forget Desgin Patterns, the behavioural building blocks of our language. Refactoring guru is also a good place to read about it

The code #

And down the low level is the code, one more plcae to reflect the decisions I’ve made. Going to the place where the conversion happens is at the ConvertPosts action. Simple, neat and self explaining code is the place to start understanding the whole code going back to the generic OriginlPost/DestinantionPost, down to the multiple implementations of each source and destination repositories to do the whole convertion trick

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ConvertPosts(
    private val source: SourcePosts,
    private val destination: DestinationPosts,
    private val textToSlug: ExtractSlugService,
    private val textToTitle: ExtractTitleService
) {
    operator fun invoke() {
        source.getAll().map { post ->
            post.asDestination(
                textToSlug(post.fullText),
                textToTitle(post.fullText)
            )
        }.forEach { destination.save(it) }
    }
}

Hope you enjoy the reading and the code as much as I enjoyed writing them!