Façade Design Pattern
Hi , thanks for stopping by!
I am full-stack developer and I'm passionate about making complex concepts clear through code and visuals. After all, a picture (and a code snippet) is worth a thousand words!
I hope you enjoy my blog.
Façade means "Frontage" or "face" . Face of the multiple subsystem .

/**
* SmartPerson(Client).
*/
public class SmartPerson {
private SmartHomeSystem homeSystem = new SmartHomeSystem();
public void myMovieSetup() {
homeSystem.movieNightSetup();
}
}
/**
* SmartHomeSystem(Facade).
*/
public class SmartHomeSystem {
private SmartLight light = new SmartLight();
private SmartWindow window = new SmartWindow();
private SmartAC ac = new SmartAC();
private SmartMovieSystem moviesys = new SmartMovieSystem();
public void movieNightSetup() {
System.out.println("Movie Night Set up flow started ");
window.close();
ac.on();
moviesys.movieTVSetup();
light.off();
System.out.println("Movie Night Set up - Successfully ");
}
}
/**
* SmartLight(SubSytem Class).
*/
public class SmartLight {
public void on() {
System.out.println("Light On");
}
public void off() {
System.out.println("Light off");
}
}
/**
* SmartAC(SubSytem Class).
*/
public class SmartAC {
public void on() {
System.out.println("AC On");
}
public void off() {
System.out.println("AC off");
}
}
/**
* SmartTV(SubSytem Class).
*/
public class SmartTV {
public void on() {
System.out.println("TV On");
}
public void off() {
System.out.println("TV off");
}
public void playmovie() {
System.out.println("Palying the movie");
}
}
/**
* SmartWindow(SubSytem Class).
*/
public class SmartWindow {
public void close() {
System.out.println("Window Close");
}
public void open() {
System.out.println("Window Open");
}
}
/**
* SmartSpeaker(SubSytem Class).
*/
public class SmartSpeaker {
public void highVolume() {
System.out.println("Speaker high Volume");
}
public void mediumVolume() {
System.out.println("Speaker medium Volume");
}
public void lowVolume() {
System.out.println("Speaker low Volume");
}
}
/**
* SmartMovieSystem(AdditionalFacade)(optional).
*/
public class SmartMovieSystem {
private SmartTV tv = new SmartTV();
private SmartSpeaker speaker = new SmartSpeaker();
public void movieTVSetup() {
System.out.println("Movie TV Set up flow started ");
tv.on();
speaker.highVolume();
tv.playmovie();
System.out.println("Movie TV Set up - Successfully ");
}
}
public class PatternTest {
public static void main(String[] args) throws Exception {
SmartPerson person = new SmartPerson();
person.myMovieSetup();
}
}
// output
Movie Night Set up flow started
Window Close
AC On
Movie TV Set up flow started
TV On
Speaker high Volume
Palying the movie
Movie TV Set up - Successfully
Light off
Movie Night Set up - Successfully