I was wondering if there was any best practices or rules that can help to determine whether deep navigation should be allowed from an object root or not. So far, I've almost always preferred to hide all implementation details, but it might be overkill.
By deep navigation, I mean something like
httpResponse.status().text() rather than
httpResponse.statusText() considering that
HttpResponse encapsulates a
The latter completely hide implementation details, but also requires more code. I understand the example is perhaps oversimplictic and
HttpResponse has no invariants to enforce other than preventing a
null status, but it's enough to expose the problem.
Please note that we can consider
HttpStatus as immutable for the example.
It might not be the best example, but we can also use any example where composition is used over inheritance.