Home United States USA — software Archiving Composition Over the Heritage With CDI Decorator and Delegator

Archiving Composition Over the Heritage With CDI Decorator and Delegator

110
0
SHARE

In this video, we’ll explore the power of interceptor and Decorator to make it easier for you to apply the Composition over inheritance principle using this powerful CDI engine.
Join the DZone community and get the full member experience.
Composite over inheritance is an OOP design principle we’ve followed for several years. Like me, you might have seen it in the Effective Java book, and we have wanted to pursue it since then. 
The inheritance brings several pitfalls, such as maintainability and a clear code. Beyond the semantics, the sample that I love to use is the cake that needs Salt. It does not make sense for a Cake to extend a Sea only because it needs Salt. In this case, it is a much better composition as well. 
On the CDI, we can avoid the inheritance in several moments with the Decorator and the interceptor.
The first step is the Decorator, which creates a structure to attach new behaviors to objects.

Continue reading...