cover-img

Code Smell 22 - Helpers

Helpers don't help. They are a non-cohesive bunch of messy subroutines.

5 November, 2022

0

0

0

Do you need help? Who are you gonna call?

TL;DR: Helpers don't help. They are a non-cohesive bunch of messy subroutines.

Problems

Readability

The Least surprise principle

Bijection Fault

Static methods

Solutions

1.

Find a suitable name

2.

If the helper is a library, break all the services as different methods.

3.

Methods should always be fulfilled by objects. Static methods are another code smell.

4.

Avoid extracting the helpers to Anonymous Functions.

Sample Code

Wrong

Notice static methods.

Right

or we can make the former Helper stateless for reuse…

Detection

Code naming standards should forbid classes with this name on them.

Tags

Namings

Conclusion

This is a well established cultural name and a legacy habit from structured programming.
Most developers are reluctant to let old habits go.
We must be aware of the damage this kind of names are bringing us.

Relations

Also known as

Utils

More Info

This article is part of the CodeSmell Series.

0

0

0

Maxi Contieri

Buenos Aires, Argentina

🎓Learn something new every day.📆 💻CS software engineer 👷coding👨🏽‍🏫teaching ✍🏾writing 🎨Software Design 🏢SOLID 🌉TDD 👴Legacy 💩Code Smells

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.