Roadmap › OOP Concepts in C# › Module: Relationships and Design
Lessons in this course (15)
15. Cohesion, coupling and the Law of Demeter
AdvancedMediumLesson 15 of 15
- High cohesion: a class does one focused job; its members belong together.
- Low coupling: classes depend on few others, through abstractions.
- Law of Demeter ("talk to friends, not strangers"): avoid
order.Customer.Address.City.Namechains; ask the object to do the work:order.ShippingCity(). - Tell, don't ask: tell the object what to do rather than pulling data out and deciding for it.
These lead straight into SOLID, covered in the next course.