Hi Igor, thanks for the user-friendly articles on design patterns (rare to find those in web).
I just wanted to point out two issues:
- In your Decorator example code, since you use the lines
$door = new Door();
$window = new Window();
shouldn’t the two lines
$smartDoor = new SmartOpener(new Door());
$smartWindow = new SmartOpener(new Window());
be replaced with the two lines below?
$smartDoor = new SmartOpener($door);
$smartWindow = new SmartOpener($window);
2. So, we could phrase in other words that with the Decorator pattern we pass the initial class as an argument to the Decorator class and the Decorator class implements the additional functionality in a public function. Could that be a correct definition?