In OOP, Encapsulation is bundling the data with logic within the class. In short, we tell the object what to do rather than ask for the data (Tell Don’t Ask Principle).
Ask too much to the object will create the smell of code called Feature Envy or Inappropriate Intimacy. The objects are not loose coupling with each other (coupler).
Furthermore, the object-oriented design should follow the Law of Demeter (a.k.a Principle of Least Knowledge) in order to loosely couple
- Each unit should have only limited knowledge about other units: only units “closely” related to the current unit.
- Each unit should only talk to its friends; don’t talk to strangers.
- Only talk to your immediate friends.