2016-06-19

The virtues of duplication

Few weeks ago I began to prepare a copy of the Green Ruby Template system for the usage of the Remote Meetup team. It’s kind of ironic because, from some point of view, this code is a sin and was not written in the perspective to be generic. It’s deliberately not constrained to code best practices, it’s joyfully messy and blatantly suboptimal. It was a quick and dirty scripting solution, it could have been a set of shell scripts, well it happens to be using ruby. Check it out if you don’t believe me.

But it’s doing the job for years now. It’s a builder code, so it’s run as a convenience only a few times a week, it doesn’t really need to be fast. It just needs to do the job. Trust me I like good code, with clean design and full test coverage. But this one was just an intimate assistant of mine which was not really a software. Just some automation scripts.

And now here it is, I get to face a situation where some friends need the same setup and I can’t just give them the code, it’s so custom. But there have been only a few changes to make and it was ready. But the interesting part is in the process. While duplicating the code for the Remote Meetup newsletter, well, I extracted some stuff, made a config file to remove various hardcoded things.

Well it is still a big ball of dirty code, but in the duplication, it got more generic. I love that feeling which brings the software development world closer from the biological world. There is some kind of evolutionary process going on in the life of a software. It takes many forms and I like it when I get reminded of those similarities. I could go on and on about the topics that an open source ecosystem is necessary for the diversity of code to flourish and make evolution possible in a totally Darwinian way.

So this simple operation was just illustrating one principle: when you share your code you shape it and make it more generic in the process. It can have various beneficial side effects beyond the single act of duplication and adaptation. I find it’s also true when you publish your code as an open source project. If it gets some traction and people start to use it, they will import their context in your initial ecosystem and bring the same kind of adjustments. Making it stronger, in some way.

Anyways, the Remote Meetup News website and newsletter generator is now ready, and you may find that the design is kind of familiar. Well, the rule of the path of least resistance also apply here for sure. I begin to apply back on Green Ruby the changes I made over there. I suspect the third duplication, of any, will be the extraction of the common parts in a separate codebase, like a gem with a lib.

comments powered by Disqus