Code Smell 16 - Ripple Effect
Small changes yield unexpected problems.
Problems
- Coupling
Solutions
- Decouple.
- Cover with tests.
- Refactor and isolate what is changing.
- Depend on interfaces.
Examples
- Legacy Systems
Sample Code
Wrong
Right
Detection
- It is not easy to detect problems before they happen. Mutation Testing and root cause analysis of single points of failures may help.
Tags
- Legacy
Conclusion
There are multiple strategies to deal with Legacy and coupled systems. We should deal with this problem before it explodes under our eyes.
Relations
More info
Credits
Photo by Jack Tindall on Unsplash
Architecture is the tension between coupling and cohesion.
Neal Ford
This article is part of the CodeSmell Series.
Software Engineer
Decoupling a clock isn't the best example of it, I suppose, because I didn't quite get it 😁
When I work with database for bot, as example, I plant queries in methods of accompanying Models. Does it somehow introduce a Ripple Effect?
which would be the source of time?
How would you test it?
Remember tests must be in full environment control and have no globals involved and 'now()' is a global out of control.
if you couple your model to your database you will indeed have lots of coupling.
Databases are accidental and, thus, unrelated to business models.
Create your bot. Create your chats, create your conversations and test them.
The database comes later on.
Comments (2)