cover-img

Code Smell 29 - Settings / Configs

24 November, 2022

4

4

0

Changing system behavior in a control board is the customer's dream. And the software engineer's nightmare.

Problems

Duplicated Code

Global usage

Testability and explosion of testing scenarios.

Complexity

Solutions

1.

Avoid Settings

2.

Create polymorphic objects. Inject them externally.

Examples

External Connection Settings

User settings

Sample Code

Wrong

Right

Detection

This is an architectural pattern so it should be controlled/avoided by design policies.

Exceptions

Sometimes we use Feature togging as a safeguard mechanism. This is acceptable in a legacy system. These toggles should be very short-lived in a CI/CD system.

Hyper parameter settings should be managed by configuration objects.

Tags

Globals

Conclusion

Setting runtime behavior is great for software systems.
We should configure our objects, so they can behave in different ways, and we should achieve it in an explicit way with explicit behavioral objects.
In this way, our code will be more declarative, clean and testable. It is not as easy as adding an IF Statement. This kind of lazy developers bring lots of coupling and unexpected issues on our systems.

A system with 300 Boolean configurations has more test combinations (2 ^ 300), than the number of atoms in the universe (10 ^ 80).

Also known as

Feature Toggles

More Info

Simplicity is the soul of efficiency.

Austin Freeman
This article is part of the CodeSmell Series.

4

4

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.