Code like order.GetCustomer().getAddress().getZipCode() violates the Law of
Demeter. This code is coupled to the internal structure of three different
objects. Instead, have Order.getCustomerZipCode() that handles the navigation
internally.
Method chaining itself is not the problem. Fluent interfaces like
builder.setName("John").setAge(30).build() are fine because they return the
same object type, e.g., PersonBuilder.
- Design Principles | Hello Interview Low Level Design. www.hellointerview.com . Accessed Sep 10, 2026.
I don’t fully follow. Doesn’t
Order.getCustomerZipCode()have_customer.GetAddress().GetZipCode(), and therefore we’re back where we were but coupled to \(N-1\) objects?