DEV Community

Manuel Mejia
Manuel Mejia

Posted on • Originally published at blog.manuelmejiajr.com on

Clean Code, even under pressure

We all have been in the position at work when the pressure comes, and delivering on time is a "life-or-death situation". There are a lot of factors that influence a bad project planning like wrong time estimation, workload distribution, team choice, etc...and maybe it will happen more than once, after all, we are humans and we are really bad forecasting.

Certainly, nobody wants to work under pressure, we can't think clearly, we try to work faster, making more mistakes than in a normal situation, it sucks I know. In those moments we tend to focus more on delivering at all cost, even sacrificing our reputation...and that's why I wanted to write this post.

Keep in mind, when you are coding, maybe alone or within a team, you are building something to solve a problem it doesn't matter how big or small it is, I'm pretty sure that problem will evolve over the time. Having said that, more and more code will be written. This code should be maintainable over the time, therefore, setting rules, design patterns, and conventions are a "MUST".

A strong recommendation is to start wrapping all these settings before writing the first line of code because it will be very difficult to clean the mess later. Some examples of simple things to define at the beginning are:

  • Name conventions for variables and functions (Pascal case, Camel case, etc..)

  • Curly braces format, find some wise advice here

  • Line length (horizontal line of code), this questions of SO it's an interesting starting point

  • Indentation style, here you have some examples

Alternatively, and my preferred one, you can set up a linter (a tool that is used to mark the source code with some suspicious and non-structural) and set the rules for the whole team, that will force each member of the team to respect the rules. However, a linter will not help you to write rational algorithms and data structures. For this, I highly recommend you to read this set of books especially the Bob Martin's choice and long hours of code.

Also, we could be forced to skip all these rules and conventions to start working right away, but no! stop right there and take couple of hours to set the rules, this will save you a lot of time in the future. Nobody wants to deal with your messy work. After all, it's your code, your responsibility, your reputation. Be aware of all the possible consequence this could trigger, from a bad recommendation for a new position or job opportunity to the unpleasant experience of work with you. I'm sure you don't want to be on that situation, hence "Clean Code, even under pressure".

"To leave the world better than you found it, sometimes you have to pick up other people's trash."

-Bill Nye

Top comments (0)