Q1. What is the Law of Demeter and how is it related to the Factory pattern?
A: The Law of Demeter is a design guideline that talks about the following:
Each unit should have only limited knowledge of other units in the system
A unit should talk to its friends only
A unit should not know about the internal details of the object that it manipulates
The principle of least knowledge and Law of Demeter are the same and both point to the philosophy of loose coupling. The principle of least knowledge fits the use case of the Façade pattern as the name is intuitive and the word principle acts as a guideline, not being strict, and being useful only when needed.
Q2. Can there be multiple Façades for a subsystem?
A: Yes, one could implement more than one façade for a group of subsystem components.
Q3. What are the disadvantages of the principle of least knowledge?
A: A Façade provides a simplified interface for the clients to interact with subsystems. In the spirit of providing a...