3

Is this some rule that if I have multiple Facade classes they must be combined in 1 Facade Class?

For example, I have a Hospital System with different classes, like Appointment, Patient, Doctor, Medicine.

I created different Facade Classes like, OPD_Facade, Pharmacy_Facade, Visit_Facade, all of them are independent with each other and internally using the other classes and exposing simple methods. My UI (which is client of facade classes) uses appropriate facade to perform different tasks.

Do I need to create 1 central Facade class where these Facade classes must be linking together? Or this whole scheme is NOT actually Facade Pattern? The examples I am seeing on internet usually have 1 central Facade class.

sallushan
  • 179
  • 4

1 Answers1

4

The point of any facade is to provide a useful abstraction and interface for the using code. What is behind the facade, multiple functions, multiple objects, or multiple facades is not important. Which is why you have a facade in the first place. To make the complexity of structure go away. Stop focusing on the structure and focus on the way this will be used.

This means the only justification for 1 central facade class would be if there were using code that had a real need to use the whole thing. Without that, unifying everything into one facade is a pointless exercise. It's perfectly fine to use multiple facades when you have multiple uses. Just make something easy for us mere humans to understand.

candied_orange
  • 102,279
  • 24
  • 197
  • 315