The decorator in a JEE scenario
First of all, we create an Engineering interface that has the business method we want to decorate. We then create an abstract class named BasicEngineering that extends Engineering. As the following code shows, we can make an abstract EngineeringDecorator using two concrete decorators, or we can make two abstract decorator classes that implement Engineering directly. There is no obligation to keep the decorator classes concrete.
For the sake of simplicity, let's create the two decorator classes as abstract, without having to extend them from a basic decorator class. So, both the ElectronicDecorator and MechanicalDecorator classes will decorate the Engineering objects (ElectronicEngineering and MechanicalEngineering ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access