+ 1
One practical example of Facade php design pattern?
2 Answers
+ 1
In OOP, you want to make small classes that each know how to do one thing. You also want that classes depend on each other as little as possible, so changing one class doesn't mess up 20 other classes.
At some point you want to use multiple classes at once though because you're making a complicated program.
For example!
Maybe you want to send some bitcoin to somebody, and you have some classes:
- One that can send US dollars from your bank account
- One that can exchange US dollars to bitcoin
- One that manages your bitcoin wallet
- One that sends bitcoin to somebody
- An address book that knows your friends' names and bitcoin addresses
Each class can stand on it's own and doesn't need the others, which is good. But to send money it's maybe useful to build a class `BitcoinManager` that you can use like
$bitcoinManager.send("John", 50)
And it exchanges 50 dollars to bitcoin and sends it to John's wallet. That's the facade and it's where all the "messy", interconnected code goes.
0
A very interesting example!