Member-only story

All Code Smells Summarized as Time-Saving One-Liner

Arnold Abraham
8 min readAug 25, 2022

--

Is it a smell or not? Get a quick answer by One-Liner Code-Smells

Image Made By The Author Via Canva.com

Code smells are certain indicators of problems in code and express that something is wrong. It is important to pay attention to code smells.

These aren't dogmas but indicate that values may be under threat.
Values in terms of evolvability, correctness, production efficiency, and continuous improvement.

It is important to take action if a code smell makes code unchangeable.
Hence I made a list from A to Z to be used to quickly identify code smells.

Afraid To Fail

When you add extra checks to a method (outside its scope) to avoid exceptions.

Solution: A method that can fail should fail explicitly.

Alternative Classes with Different Interfaces

Two separate classes provide one or many method/s for an identical action.

Solution: Don't Repeat Yourself by merging or outsourcing.

Base Class Depends on Subclass

If a child class adapts, the parent class needs adaptation too.

Solution: Leave the kids alone. If they change, parents stay the same.

Binary Operator in Name

When your function name combines two operations in the name, it won't stick to the SRP.

Solution: Each function shall do one thing and do it well.

Boolean Blindness

Boolean arguments of a function fool you about what the value true or false truly does.

Solution: Don't create functions that accept boolean parameters.

Callback Hell

Callbacks are intentionally good, but chaining them results in something bad.

Solution: Make small interchangeable steps to gain a sequence of actions.

Clever Code

Showing off your skills can quickly end in over-complicated code, even for you.

--

--

Arnold Abraham
Arnold Abraham

Written by Arnold Abraham

JavaScript, TypeScript and C#/.NET Tutorials/News/Best Practices by a German Software Engineer - Fun helps you to learn on the fly --> arnoldcode.com

Responses (3)

Write a response