Clean Code: Introduction


Two years ago I have switched from Java/Kotlin Android development to JavaScript Full Stack web development. Because of that I have a lot of new insights that I want to share with the reader. One of the biggest realizations I have had is no matter what platform or language or framework you are using, the fundamental Clean Code principles DO NO CHANGE. 

These series is dedicated to [re]discovering the Clean Code principles. Strongly influenced by "Clean Code" by Robert C. Martin, I will be covering the most important principles to writing clean, readable and maintainable code.

Good developers are modern craftsman. Knowing how to make your code do what you want it to do is easy. Making that code maintainable is the real challenge. As new abstract languages and frameworks are created, and as number of programmers doubles every 5 years, knowing how to write clean code is the most important challenge for any developer.

Good code matters!

Working mess is NOT better than nothing. It is actually worse. Bad code can bring a company down, it can bring a network down. Bad code costs money and if the code is mission critical, it can cost lives. Recent incidents with Boeing MAX has showed us the dangers of bad code.  

Make it Right!

"Going back to clean up the code" usually means NEVER. How many times have you sworn to go back to clean up and refactor the code, to find yourself months later cursing the mess it has snowballed into. The messier the code the more productivity is lost while adding new features. Every developer spends extra time trying to works with messy code. It might take longer to write clean and thought out code from the start but in the long run its exponentially more productive for the future development on that code base. Messy code requires developers to understand the entire code before making any changes. Productivity pressure makes the developers make a bigger mess over time. So redesigning the code takes more time and effort than keeping it clean from the start.

Attitude is key!

Unprofessionalism leads to bad code. Managers obsess with schedule, good developer obsesses with good, quality code. The only way to consistently meet deadlines is to keep the code as clean as possible. Messy code will bring projects to a snail pace and cause developers to miss deadlines. 

What should it look like?

  • Code has to be "elegant" or pleasing to look at.
  • Must do one thing well. Bad code tries to do too much.
  • Restricts to only one way of doing a thing rather than many.
  • Looks like it was written by someone who cares.
  • Small abstractions help move fast and change underlying implementation if needed.
  • Ratio of reading code to writing code should be actively lowered.
  • Code that is easy to read is easy to work with.
Hopefully this introduction convinced you of the importance of writing good code, and gave you some ideas to get your started. In the next post we will be covering specific techniques and rules to help you write clean code.


Comments

  1. Great articles! You could also earn cryptocurrency (ETH) by inserting a simple HTML snippet from Cryptoads.xyz to your blog. Just insert your Ethereum public key into it and you are good to go. Your ad space is then auctioned off every 2 weeks and you earn 90% directly into your Ethereum account. Awesome new way to monetize a cryptocurrency blog like yours. If you have any questions just hit me up at info@cryptoads.xyz. Happy blogging ;)

    ReplyDelete

Post a comment

Popular posts from this blog

Android Architecture Components : LiveData

Android Data Binding : Dynamic RecyclerView Adapter

Building a Cryptocurrency with Kotlin : Part 1