Facade 패턴

 - 코드 랩핑(Code Wrapping)을 통해 의존성을 낮춘다.


  1. class Hotel {
  2.         // 호텔 정보
  3. }
  4.  
  5. class Flight {
  6.         @SuppressWarnings("unchecked")
  7.         public List<Flight> getFlightsFor(Date from, Date to) {
  8.                 return Collections.EMPTY_LIST;
  9.         }
  10. }
  11.  
  12. class HotelBooker {
  13.         @SuppressWarnings("unchecked")
  14.         public List<Hotel> getHotelNamesFor(Date from, Date to) {
  15.                 return Collections.EMPTY_LIST;
  16.         }
  17. }
  18.  
  19. class FlightBooker {
  20.         @SuppressWarnings("unchecked")
  21.         public List<Flight> getFlightNamesFor(Date from, Date to) {
  22.                 return Collections.EMPTY_LIST;
  23.         }
  24. }
  25.  
  26. class TravelFacade { // 코드 랩핑, 사용자는 Hotel, FLight에 대해 알 필요 없다.
  27.         private HotelBooker hotelBooker;
  28.         private FlightBooker flightBooker;
  29.  
  30.         public void getFlightAndHotels(Date from, Date to) {
  31.         }
  32.  
  33.         public HotelBooker getHotelBooker() {
  34.                 return hotelBooker;
  35.         }
  36.  
  37.         public FlightBooker getFlightBooker() {
  38.                 return flightBooker;
  39.         }
  40. }
  41.  
  42. public class Ex1 {
  43.  
  44.         public static void main(String[] args) {
  45.         }
  46.  
  47. }


+ Recent posts