Law of Demeter
A method should talk to its direct collaborators, not reach deep into their parts.
What is Law of Demeter?
The Law of Demeter ("talk only to your friends") says a method should use its own objects, not reach through them into their parts. Avoid chains like order.Customer.Address.City.
// Reaching through objects
var city = order.Customer.Address.City;
// Asking directly
var city = order.ShippingCity();
Level: Freelancer · More OOP terms at this level
Updated