10 code smells to avoid

What are the 10 common Code Smells to avoid in Software Development 😨

List of Code Smells that you may be committing when developing software.

Pravin Uttarwar
3 min readJul 12, 2022

In the late 1990s, Kent Beck, the originator of extreme programming, stressed the importance of design quality when designing software and popularized the phrase Code Smells.

Code smells are not bugs or errors. Instead, these are absolute violations of the fundamentals of developing software that decrease the quality of code.

Code smell meme
Code smell meme

Here are some of the most common code smells that you may be committing when developing software.

  1. Long functions:

Since the start of programming, people have recognized that the longer a function is, the more difficult it is to grasp. In previous languages, subroutine calls had a large overhead, discouraging people from employing short functions. Modern languages have almost eliminated this cost for in-process calls. Typically, as the length of a function increases, so does its complexity, and the code becomes less maintainable.

2. Long Parameter lists:

A method call with a long parameter list is a code smell. It implies that something isn’t quite right with the code’s implementation. There is no clear and fast rule over the number of sorted lists that are too many. More than three or four is commonly regarded as excessive, as it affects the code’s readability and understanding, as well as its vulnerability to flaws and mistakes.

3. Confusing names:

Learning all the varied name conventions from language to language may be challenging. Even more, confounding is when developers differ over what constitutes the ideal naming strategy. It is generally believed that a variable name that is more complicated than a noun is a code smell.

4. Temporary field:

If you have a class instance variable that has only been used once, you have a code smell called Temporary Fields. Temporary fields are often generated in the case of such algorithms that involve numerous inputs.

5. Data clumps:

When more than one piece of data is typically found together, it is referred to as a data clump. Identical classes of variables appear in various sections of the code at times, such as parameters for connecting to a database. These data classes are often the result of a weak program structure.

6. Duplicated code:

While there are initiatives that allow you to replicate code from a publicly accessible repository, this is not a reliable approach. Many programmers who copy code from places like GitHub don’t double-check the code’s integrity.

7. Mismanaged class size:

SOLID design principles are meant to help developers achieve flexible, maintainable, and understandable software. Most programmers implement SOLID design principles but typically mismanage the single-responsibility principle.

8. Poor methods name:

The name of methods is typically overlooked by developers. All methods end up being named in a generic way, making it difficult to communicate anything to code auditors

9. Comments:

It is important to leave comments in your code to help developers understand your code. But leaving too many comments ruins the flow of your code. Comments can be very helpful when it comes to explaining the logic behind specific parts of your code.

10. Conditional statements:

Conditional statements must be used to back up your approach patterns. On the one hand, most developers do not utilize conditional statements, but on the other hand, some developers use them far too frequently.

How to find and remove Code Smells from your project

There are some ways you can remove code smells. One of them is using an automated code review tool that will help you to sniff out the smelly code and also give suggestions on how to resolve it. Such a tool is CodeGrip, which is free to try and made for developers and leaders who love quality codes.

To read more on the list of code smells, you can check out this article — Top reasons that make your code smell.

--

--

Pravin Uttarwar
Pravin Uttarwar

Written by Pravin Uttarwar

CTO at Mindbowser | MIT Alumnus | Expert in AI, FHIR, & EHR | Built 100+ healthcare solutions | Co-host, Namaste Tech Talks | Let’s innovate in healthcare!

No responses yet