Thoughts on Writing Clean Code
I hope many developers read this because this is me speaking to you. Been a developer myself in different positions with different responsibilities, I need to challenge the status quo. The work we produce takes a lot of our time and effort. Any work which is done usually needs to have a value otherwise, why do any work at all. We as software developers or software engineers like to think that the code we write is what we do, we want it to be clean, understandable, smart, avoiding hacks or code repetition, shining away from boilerplate. You know what I mean, we want our code to be good because we value a good architecture, we care about whatever framework we want to apply to our code so it is structured in a certain way. All these qualities we can summarise as “I want my code to be as good as possible”. If this becomes your main value, you start to judge other peoples code like not clean enough, or this is using string comparison, why you won’t move this into a view model, why are you using Boolean when you could use an enum. You start to pick others to work apart. And you think that you are doing something meaningful. But what you doing is that you are trying to make the code look good. You are investing your time, other’s developers time to make your code look good.
You can do better by writing as little code as possible. If you think that you can make code better by writing more code, you are already made a tradeoff and increased your code size, potentially scope for bugs to slip through, you have increased the amount of code you have to maintain and test. Simply put, less code is better than more code. Writing more code is not a good option. Less code you have is better.
Here are good values for all developers.
- As little code as possible to makes something happen
- As simple as possible
- How many classes and protocols do you need to introduce
- Write your code with limited functionality instead of using “this does it all for you” third-party library
Think about what you doing, you are making a product for others people to use. Most of the code changes you make won’t be noticed by your client. Value your time, make sure your client is happy. Value others developers time because they have clients to make happy too. The code is not a purpose it is just a means to an end, it is a tool to make something happen, to make your product live and usable for other humans. Delivering something as quick as possible with as little code as possible, avoiding complexities, abstractions, third-party dependencies is what you should strike for. This should be your real value.