Façade Pattern Your Home theatre. Task list In terms of classes.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

In the name of God Fa ç ade Design Pattern Amin Mozhgani Software engineering(II)
March Ron McFadyen1 Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat.
Software Engineering Patterns: Facade Kelly Enright.
Façade Pattern Jeff Schott CS590L Spring What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance.
Design Patterns: Proxy Jason Jacob. What is a Proxy? A Proxy is basically a representative between the Client and the Component. It gives the Client a.
March 2007ACS Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to.
November Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to.
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Informatics 122 Software Design II Lecture 6 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
CS 350 – Software Design Command Object Remote Control Object.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Façade Design Pattern (1) –A structural design pattern.
+ Informatics 122 Software Design II Lecture 9 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
1 Dept. of Computer Science & Engineering, York University, Toronto CSE3311 Software Design Adapter Pattern Façade pattern.
SOFTWARE DESIGN AND ARCHITECTURE
Interfaces. –An interface describes a set of methods: no constructors no instance variables –The interface must be implemented by some class. 646 java.
The Adapter Pattern SE-2811 Dr. Mark L. Hornick 1.
Georgia Institute of Technology Movies part 2 Barb Ericson Georgia Institute of Technology April 2006.
CPSC1301 Computer Science 1 Chapter 14 Creating and Modifying Movies part 2.
Facade Introduction. Intent Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
The Façade Pattern SE-2811 Dr. Mark L. Hornick 1.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Creational Pattern: Factory Method At times, a framework is needed to standardize the behavior of objects that are used in a range of applications, while.
Week 9, Class 3: Model-View-Controller Today Happens-Before Adapter and Façade Pattern (high-level) Tuesday: Project code due, 11pm Wednesday: Quiz Choose.
Chapter 9 Putting together a complete system. This chapter discusses n Designing a complete system. n Overview of the design and implementation process.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
CS 210 Final Review November 28, CS 210 Adapter Pattern.
State Design Pattern. Behavioral Pattern Allows object to alter its behavior when internal state changes Uses Polymorphism to define different behaviors.
JAVA DESIGN PATTERN Structural Patterns - Facade Pattern Presented by: Amit kumar narela Ise Ise
Adapter and Façade Patterns By Wode Ni and Leonard Bacon-Shone.
Interfaces and Polymorphism CS 162 (Summer 2009).
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Control Panel in Lecture Theatres Learning Environment Services.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
StarBuzz Coffee Recipe Boil some water Brew coffee in boiling water Pour coffee in cup Add sugar and milk Tea Recipe Boil some water Steep tea in boiling.
Façade Design Pattern by Ali Alkhafaji Unified interface for a set of interfaces to promote readability and usability.
The radio  Has a case  The case separates the controls on the outside (the client interface) from the electronic guts inside (the implementation).
CS 350 – Software Design The Facade Pattern – Chapter 6 Many design patterns are catalogued in the “Gang of Four” text. I find their definitions not to.
Command Pattern Encapsulation Invocation. One size fits all.
Programming with Patterns Jeremy Cronan Alliance Safety Council
Presented by FACADE PATTERN
BTS530: Major Project Planning and Design
Object-Orientated Analysis, Design and Programming
Describe ways to assemble objects to implement a new functionality
using System; namespace Demo01 { class Program
Façade Pattern:.
Design Patterns Lecture part 2.
Chapter 6 Queue.
Software Design & Documentation
By SmartBoard team Adapter pattern.
Composite Design Pattern
Decorator Design Pattern
CS 350 – Software Design The Facade Pattern – Chapter 6
7. Decorator, Façade Patterns
Object Oriented Design Patterns - Structural Patterns
class PrintOnetoTen { public static void main(String args[]) {
Chapter 6 Queue.
ADAPTER FAÇADE FACTORY OBSERVER SINGLETON STRATEGY
7. Decorator, Façade Patterns
10. Façade Pattern SE2811 Software Component Design
Software Design Lecture : 35.
Lecture 22: Number Systems
CPSC 233 Tutorial 13 March 11/12th, 2015.
Presentation transcript:

Façade Pattern Your Home theatre

Task list

In terms of classes

But there’s more??

Lets façade it

Façade steps 1.Create a new class HomeTeathreFacade, which exposes simple methods like WatchMovie(). 2.The façade class treats home theatre component as sub system, and calls on the sub system to implement its WatchMovie() method. 3. Your client code now calls methods on the home theatre Façade, not on the subsystem. So now to watch a movie we just call one method, watchMovie(), and it communicates with the lights, DVD player, projector, amp, screen and popcorn maker for us 4.The Façade still leaves the subsystem accessible to be used directly. If you need the advanced functionality of the subsystem classes, they are available for use.

Home Theater Facade public class HomeTheaterFacade { Amplifier amp; Tuner tuner; DvdPlayer dvd; CdPlayer cd; Projector projector; TheaterLights lights; Screen screen; PopcornPopper popper; public HomeTheaterFacade(Amplifier amp, Tuner tuner, DvdPlayer dvd, CdPlayer cd, Projector projector, Screen screen, TheaterLights lights, PopcornPopper popper) {

this.amp = amp; this.tuner = tuner; this.dvd = dvd; this.cd = cd; this.projector = projector; this.screen = screen; this.lights = lights; this.popper = popper; } public void watchMovie(String movie) { System.out.println("Get ready to watch a movie..."); popper.on(); popper.pop(); lights.dim(10); screen.down(); projector.on(); projector.wideScreenMode(); amp.on(); amp.setDvd(dvd); amp.setSurroundSound(); amp.setVolume(5); dvd.on(); dvd.play(movie); }

public class CdPlayer { String description; int currentTrack; Amplifier amplifier; String title; public CdPlayer(String description, Amplifier amplifier) { this.description = description; this.amplifier = amplifier; } public void on() { System.out.println(description + " on"); } public void off() { System.out.println(description + " off"); } public void eject() { title = null; System.out.println(description + " eject"); } public void play(String title) { this.title = title; currentTrack = 0; System.out.println(description + " playing \"" + title + "\""); }

Starting the Movie: public class HomeTheaterTestDrive { public static void main(String[] args) { Amplifier amp = new Amplifier("Top-O-Line Amplifier"); Tuner tuner = new Tuner("Top-O-Line AM/FM Tuner", amp); DvdPlayer dvd = new DvdPlayer("Top-O-Line DVD Player", amp); CdPlayer cd = new CdPlayer("Top-O-Line CD Player", amp); Projector projector = new Projector("Top-O-Line Projector", dvd); TheaterLights lights = new TheaterLights("Theater Ceiling Lights"); Screen screen = new Screen("Theater Screen"); PopcornPopper popper = new PopcornPopper("Popcorn Popper"); HomeTheaterFacade homeTheater = new HomeTheaterFacade(amp, tuner, dvd, cd, projector, screen, lights, popper); homeTheater.watchMovie("Raiders of the Lost Ark"); homeTheater.endMovie(); }

definition Façade pattern provides a unified interface to a set of interfaces in a subsystem. Façade defines a higher level interface that makes the sub system easier to use.

Who does what? PatternIntent DecoratorConvert one interface to another Adapter Don’t alter interface, but add responsibility FaçadeMake Interface simpler