๋ณต์กํ ๊ณผ์ ์ ๊ฐ๋จํ๊ฒ ์ ๊ณต
Intent
Facade is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes.
Implementation

Applicablity
- ๋ณต์กํ Subsystem์ ์ธํฐํ์ด์ค๋ฅผ ์ ํํ๊ณ ์ถ์๋
- Subsystem์ ๊ณ์ธต ๊ตฌ์กฐ๋ก ๋ํ๋ด๊ณ ์ถ์๋
Examples
javax.faces.context.ExternalContext
uses ServletContext
, HttpSession
, HttpServletRequest
, HttpServletResponse
and others inside.Code Exampl
package oodesign.design.structural.facade.subsystem; class HelpSystem01 { public HelpSystem01(){ System.out.println("call constructor: "+getClass().getSimpleName()); } public void proc(){ System.out.println("call proc: "+getClass().getSimpleName()); } } class HelpSystem02 { public HelpSystem02(){ System.out.println("call constructor: "+getClass().getSimpleName()); } public void proc(){ System.out.println("call proc: "+getClass().getSimpleName()); } } class HelpSystem03 { public HelpSystem03(){ System.out.println("call constructor: "+getClass().getSimpleName()); } public void proc(){ System.out.println("call proc: "+getClass().getSimpleName()); } }
package oodesign.design.structural.facade.subsystem; public class Facade { private HelpSystem01 helpSystem01; private HelpSystem02 helpSystem02; private HelpSystem03 helpSystem03; public Facade(){ helpSystem01 = new HelpSystem01(); helpSystem02 = new HelpSystem02(); helpSystem03 = new HelpSystem03(); } public void proc(){ helpSystem01.proc(); helpSystem02.proc(); helpSystem03.proc(); } }
package oodesign.design.structural.facade; public class Main { public static void main(String[] args) { new Facade().proc(); } }
Facade
๊ฐ package-private
์ผ๋ก ์ ์๋ HelpSystemN
ํด๋์ค์ ๋ํ ์
๊ตฌ๋ฅผ ์ ๊ณตํด์คSpecific problems
- Facade๋ ์ผ๋ฐ์ ์ผ๋ก Singleton ์ผ๋ก ์ ๊ณต๋๋๊ฒ์ด ์ข๋ค.