loading...

The Lazy developer

ducaale profile image Mohamed Dahir ・2 min read

I was telling a student to rewrite her code using a loop. "But loops are too complex" she protested "why do I have to when I can just copy-paste my code by hand!". It turns out that she had a good point. Why she has to replace her implementation to another if both were leading to the same result or why should anyone in the world care how a piece of code is written as long as it is fulfilling its purpose. The answer is code maintenance.

In most software, maintenance costs are just as important if not more, than what goes into writing the code in the first place. If you think about it, initial costs are one-time payment as opposed to maintenance costs which happen throughout the lifetime of the software. To reduce future maintenance costs, the code has to be small, easy to understand and easy to extend. But doing all of the three is no small feat and takes a substantial amount of resources to achieve.

But writing maintainable software is not an all or nothing goal. We can decide how much we want code to be maintainable by looking at how much requirements are expected to change in the software's lifetime. It is important to note that not every type of software has to be written with maintainability in mind.

Of course, a student in high school is not going to worry about all of this so how we might assign coursework that steers them toward writing a maintainable code? I would say by simulating real-world software development; Evolving requirements and tight deadlines. Evolving requirements is the most interesting of the two. I have recently discovered Advent of code and I like how their Intacomputer puzzles force you to revise and build upon your earlier code. Tight deadlines are not as important as the first one but they prepare you for the real world and teach you not to be too obsessive about your code.

A lecturer once told us that the best programmers are the ones who aim to do the least amount of work or in other words the laziest ones. It is also something that I have been observing from my colleagues at work. Always strive to do the thing that will reduce your work now and in the future.

Posted on by:

Discussion

pic
Editor guide