cover-img

Code Smell 08 - Long Chains Of Collaborations

Making long chains generate coupling and ripple effect. Any chain change breaks the code.

6 August, 2022

3

3

0

TL;DR: Just sent messages to your acquaintances.

Problems

Coupling

Break encapsulation

Solutions

Create intermediate methods.

Think about Law of Demeter.

Create higher level messages.

Sample Code

Wrong

Right

Detection

Automatic detection is possible using parsing trees.

Also Known as

Message Chains

Law of Demeter

Relations

More Info

Tags

Declarative

Encapsulation

Conclusion

Avoid successive message calls. Try to hide the intermediate collaborations and create new protocols.

Credits

Photo by Chewy on Unsplash
This article is part of the CodeSmell Series.

javascript

programming

3

3

0

javascript

programming

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.