Class Coupling1 min read
What is class coupling?
Class coupling is a measure of class complexity and it’s subclasses. It is showing us how deep are classes interconnected.
We have two types of coupling:
- Tight coupling
- Loosely coupling
Tight coupling is when one class is dependent on the other class and each class change triggers rebuilding of other (dependent) class.
2. Loosely coupling
This type of coupling is ideal and makes perfect software. Why? Because when we change one class we dont want to change half of the application or we don’t want to rebuild whole application beacuse of one class change.
How do we build loosely coupled apps? We build them by:
- Class relationships ( inheritance or composition )
When creating relationships between classes we use inheritance and/or composition.
Preffered way of building relationships is by using composition.
Facebook Twitter Evernote Hacker News Gmail Print Friendly Yahoo Mail reddit LinkedIn Blogger Tumblr Like In my latest Youtube video,…