Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

17695 - Design Patterns Name: Rithik Sachdev

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.

A. How can you implement this pattern in this context?

➢ Draw the modified class diagram incorporating the Façade pattern.


➢ Identify the Façade object and its methods.
Answer:

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.

➢ Describe how your design reduces the coupling.

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:

Facade Mediator Suitability in this


context

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.

Flexibility The facade design The mediator pattern In this application


pattern can provide a decouples the context, the client is
simple default view of interacting objects directly interacting
the subsystem that is from each other. This with the platform
good enough for means that the subsystem. To
most clients but for objects do not need resolve the problem
clients with more to know about or based on the
customizability, refer to each other flexibility offered,
fine-grained directly. Instead, they facade design pattern
functionality cannot communicate with suits the problem
be fulfilled using the each other through better because the
facade design the mediator object. main concern is the
pattern. It allows This makes the code highly coupled client
flexibility to add more flexible and and platform
polymorphic methods easier to maintain, as subsystem. By using
to provide changes to one this design pattern
customization object do not require we can isolate the
flexibility but it can changes to the other client from the
result in maintenance objects. Moreover, platform subsystem
issues for instances mediator replaces which can change
with numerous many-to-many over time, giving us
method variants. interactions the flexibility required
with one-to-many and shielding the
interactions between client from the
the mediator and its platform using the
colleagues. facade.
One-to-many
relationships are
easier to understand,
maintain, and extend.

Directionality The facade design The mediator design In the application


pattern consists of pattern consists of context, we are not
one-directional bi-directional provided with the
communication. The relationship between details of the
client subsystem the colleague and relationship between
communicates with mediator. The the classes of
the facade object. colleague objects different subsystems
The facade object communicate with the and between the
communicates with mediator object to subsystems.
the subsystem interact with each Therefore, the facade
objects. The other. The mediator design pattern is
subsystem objects object then more applicable. It
communicate with coordinates the provides us with
each other through communication required interaction
the facade object. between the between the client
colleague objects. and the subsystems.
Additionally, if we
were given
requirements such as
gathering booking
information, then a
mediator design
pattern with
bi-directional
communication would
benefit the system
design more than the
facade design
pattern.

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.

You might also like