Here the client creates and coordinates five subsystems itself. The interface is "chatty": the client must make a fixed list of calls, in order, just to book one ticket.
1. Key Issues in this Design
Tight Coupling (System Fragility)
The Issue: The Main class is directly dependent on five separate concrete classes: PaymentService, SeatReservationService, NotificationService, LoyaltyPointsService, and TicketService.
The Impact: If any service changes a method signature (its name or inputs) or a constructor, the client breaks. The client "knows" too much about how the theater system works inside.
Violation of the "Law of Demeter"
The Issue: The Law of Demeter says to talk only to your close neighbors. Here the client talks to "strangers" (internal subsystems) it should not need to know.
The Impact: The client does not ask for a "Booking". It handles the payment, the seating and the ticket itself. So changes inside the subsystems reach the high-level code and break it.
Poor Reusability and Maintenance
The Issue: The booking steps sit in the Main method and would be copied elsewhere.
The Impact: To offer "Movie Booking" in a mobile app or a website, you would copy-paste this 10-line sequence. If the business rule changes (e.g., the ticket must be generated before points are added and the confirmation is sent, the reverse of this code), you must find and fix every copy.
High Cognitive Load
The Issue: A developer must learn the exact order of the calls to avoid bugs (e.g., accidentally generating a ticket before confirming payment).
The Impact: People make more mistakes, and new team members find the code harder to follow.
2. Structural Analysis
Component
Status
Observation
Client (Main)
Overburdened
Creates, coordinates and runs five subsystems.
Subsystems
Exposed
Every internal service is visible to outside code, so there is more "surface area" (more places) for bugs.
Workflow
Unprotected
No single "entry point" makes sure the booking steps are followed correctly.
3. Summary of the "Smell"
When a client needs to interact with a large number of diverse classes to perform a single task, the client is too complex. The Facade Pattern fixes this with a "Simplified Entry Point", a single class that makes these calls behind the scenes.
1package DesignPatterns.StructuralPatterns.FacadeDesignPattern.Before;23// Subsystem 1: Payment handling4class PaymentService {5 public void makePayment(String accountId, double amount) {6 System.out.println("Payment of ₹" + amount + " successful for account " + accountId);7 }8}910// Subsystem 2: Seat management11class SeatReservationService {12 public void reserveSeat(String movieId, String seatNumber) {13 System.out.println("Seat " + seatNumber + " reserved for movie " + movieId);14 }15}1617// Subsystem 3: Communications18class NotificationService {19 public void sendBookingConfirmation(String userEmail) {20 System.out.println("Booking confirmation sent to " + userEmail);21 }22}2324// Subsystem 4: Rewards management25class LoyaltyPointsService {26 public void addPoints(String accountId, int points) {27 System.out.println(points + " loyalty points added to account " + accountId);28 }29}3031// Subsystem 5: Ticket generation32class TicketService {33 public void generateTicket(String movieId, String seatNumber) {34 System.out.println("Ticket generated for movie " + movieId + ", Seat: " + seatNumber);35 }36}3738/**39 * PROBLEM: The Client (Main) is tightly coupled to FIVE different services.40 */41class Main {42 public static void main(String[] args) {43 // ISSUE 1: Client "Over-knowledge"44 // The client must know the exact order of operations and which service does what.4546 // ISSUE 2: Tight Coupling47 // If the LoyaltyPointsService changes its method signature, this client code breaks.4849 // ISSUE 3: Lack of Reusability50 // To book a ticket from a Mobile App or a Web Portal, you'd have to 51 // duplicate this 10-line sequence everywhere.5253 PaymentService paymentService = new PaymentService();54 paymentService.makePayment("user123", 500);5556 SeatReservationService seatReservationService = new SeatReservationService();57 seatReservationService.reserveSeat("movie456", "A10");5859 NotificationService notificationService = new NotificationService();60 notificationService.sendBookingConfirmation("user@example.com");6162 LoyaltyPointsService loyaltyPointsService = new LoyaltyPointsService();63 loyaltyPointsService.addPoints("user123", 50);6465 TicketService ticketService = new TicketService();66 ticketService.generateTicket("movie456", "A10");67 }68}