Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOFTWARE DESIGN AND ARCHITECTURE

Similar presentations


Presentation on theme: "SOFTWARE DESIGN AND ARCHITECTURE"— Presentation transcript:

1 SOFTWARE DESIGN AND ARCHITECTURE
LECTURE 29

2 Review Design pattern classifications Structural Design Pattern
Adapter Pattern

3 Outline Structural Design Patterns Façade Pattern

4 Structural Patterns Structural class patterns:
deal with the composition of classes or objects. Structural class patterns: use inheritance to compose classes Structural object patterns: describe ways to assemble objects.

5 Façade Pattern

6 Façade Pattern Problem
There may be undesirable coupling to many things in the subsystem, or the implementation of the subsystem may change. What to do?

7 Façade – Example (Home Theater)

8 Façade - Example Starting the HomeTheater Put the screen down
Turn on the projector Dim the lights Set the projector input to DVD Turn the amplifier on Set the amplifier to DVD input Turn the DVD player on Start the DVD Player playing

9 Turning everything off at the end
Complex task to listen music When upgraded or new things added, you would have to learn new steps

10 Lights, Camera, Façade! A Façade is what you need.
With the façade pattern, you can take a complex subsystem and make it easier to use by implementing a façade class that provides a reasonable set of interfaces.

11

12

13

14 Watch a movie with ease

15 Façade - Definition Provides a unified interface to a set of interfaces in a sub-system. Defines a higher level interface that makes the subsystem easier to use.

16 Facade Problem Solution
There may be undesirable coupling to many things in the subsystem, or the implementation of the subsystem may change. What to do? Solution Define a single point of contact to the subsystem facade object that wraps the subsystem. This facade object presents a single unified interface and is responsible for collaborating with the subsystem components

17 Facade

18 Facade

19 Façade - Consequences It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use It promotes weak coupling between the subsystem and its clients. Weak coupling lets you vary the components of the subsystem without affecting its clients It doesn't prevent applications from using subsystem classes if they need to.

20

21 Façade vs. Adapter With both the Facade and Adapter pattern, we have preexisting classes. With the Facade, however, we do not have an interface we must design to, as we do in the Adapter pattern. We are not interested in polymorphic behavior with the Facade; whereas with the Adapter, we probably are. In the case of the Facade pattern, the motivation is to simplify the interface. With the Adapter, although simpler is better, we try to design to an existing interface and cannot simplify things even if a simpler interface were otherwise possible.

22 Façade Pattern - Example

23 Individual Classes

24 Façade Class

25 *

26 Summary Structural Design Patterns Façade Pattern


Download ppt "SOFTWARE DESIGN AND ARCHITECTURE"

Similar presentations


Ads by Google