Assignment 2 - Design Patterns
Assignment 2 - Design Patterns
Assignment 2
The intent of the Façade pattern is as follows:To provide a unified interface to a set of interfaces
in a sub- system. Facade defines a higher-level interface that makes the subsystem easier to
use.
The façade object is PlatforumFacade and it acts like a high level interface or an unified
interface which makes the system easier to use. The Façade methods allow the companies to
use the subsystem methods such as bookVenue(), bookInterior(), bookAdvertiser(),
bookCaterer() such that the methods are not too fine-grained i.e the PlatforumFacade does not
have methods like setStage() which could be part of building an Interior or
makeAdvertisementFlyer() which could be part of booking an advertiser and the methods are
not too coarse-grained grained because the PlatforumFacade has the methods bookVenue(),
bookInterior(), bookAdvertiser(), bookCaterer() which allows the companies to use the
subsystem in the similar way where the PlatforumFacade acts as unified interface. Additionally,
the organiseConference() method is using method overloading - polymorphism to provide one
single method which enables the specific companies such as MIT, CMU, and ThoughtWorks to
organize their conference.
This design reduces the coupling between the client subsystem and the platform subsystem by
introducing a PlatforumFacade. The client code now interacts only with the facade class,
reducing the coupling between the client and the subsystems. This helps us to modify and make
changes to plaforum subsystem without affecting the client subsystem. The client doesn't need
to know the inner workings of Venue, Caterer, Interior, and Advertiser making the codebase
more maintainable and easier to change in the future.
B. Compare the Façade and the Mediator patterns in the following aspects:
Intent The Facade design The mediator design The facade design
pattern provides a pattern defines an pattern is best suited
unified interface to a object that in this context
set of interfaces in a encapsulates the because the platform
subsystem. Facade interaction between a subsystem, and the
defines a higher-level set of objects. It client subsystem
interface that makes promotes loose (various company
the subsystem easier coupling and makes it apps) are highly
to use. easy to vary their coupled. The unified
interaction interface makes the
independently. subsystem easier to
use and abstracts the
platform subsystem
implementation which
make the code more
maintainable and
easier to change in
future. On the other
hand, the mediator
pattern is useful
when a set of objects
communicate in
well-defined but
complex ways.
Method Interface The facade pattern The method interface The facade design
defines a in the mediator pattern suits the
higher-level and design pattern problem in the given
unified interface that provides a way for scenario as the
encapsulates the the colleague objects facade design pattern
subsystems. It hides to communicate with can introduce one
the complexity of the each other through interface which can
underlying system the mediator object. encapsulate the
from the client and The mediator object details of the
makes it easier for is responsible for subsystems.
the client to use the coordinating the Moreover, we don’t
system. communication want all our business
between the logic in the mediator
colleague objects and object, this would
implementing the complicate the
business logic of the system and expose
system. the client with fine
grained methods,
making it difficult to
maintain and use.
Therefore, the facade
design pattern is
better suited to this
scenario.