From the course: C++ Design Patterns: Structural

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Applying the Facade design pattern

Applying the Facade design pattern - C++ Tutorial

From the course: C++ Design Patterns: Structural

Applying the Facade design pattern

- [Instructor] Let's refactor our code and apply the facade design pattern. First, we'll create a facade class. Let's call it ReservationsystemFacade. This class will encapsulate the functionality of our existing component classes and provide a single simplified interface for making reservations. So we'll need to add the members of each component class as private data members. First, the database. Let's call this data member m_Database. We'll also need a PaymentGateway. And finally, a MessagingService data member. Next, I create a constructor and initialize these data members as required. The constructor should be public. And I'll initialize these data members in the Initializer list, m_Database first followed by m_PaymentGateway and finally, the MessagingService data member. Next, I'll define the simplified interface, a method for making reservations. Let's call it makeReservation. Now what are its arguments?…

Contents