Code Smells Vs. Clean Code

One thing I would certainly like to avoid when coding is making my code “smell”. Code smells are often things that make code hard to read or understand. One such instance of a code smell would be a bloater as described here: https://refactoring.guru/refactoring/smells . A bloater is a section of code such as a function or class which has gotten far too large and out of proportion to understand. This happens when we don’t break down code into individual and more understandable functions and classes.

One way to avoid issues like these are to write code as cleanly as possible. This website gives 10 different ways to ensure that you are able to write clean code in any language of your choosing: https://www.unosquare.com/blog/10-tips-for-writing-cleaner-code-in-any-programming-language/ . Step number 4 in particular relates to the code smell I described earlier. It talks about how every function should at most do one thing. If code does more than one thing it should be separated into multiple different functions that work together.

Print Friendly, PDF & Email

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *