-
Be the first to like this
Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Published on
Slides from my APACHECON@HOME 2020 talk - "Favouring Composition - The Groovy Way".
Most developers I met agree that composition is better than inheritance. However, in most codebases, we see the use of inheritance where composition would have been a better design choice. Then why are the Java developers falling into this trap? It is easy to implement inheritance over composition. But we end up paying for the consequences in terms of reduced maintainability. Can language offer anything for the developers to implement composition? In this presentation, I walk you through what Groovy has to offer to make sure implementing composition is as easy as inheritance, if not simpler. I dive into three techniques for applying the composition in your Groovy applications. We start with the technique of delegation and see how easy it is to implement compositions. We uncover the limitations of this technique and introduce traits. After walking through plenty of code examples covering various aspects of using traits, we briefly touch upon functional composition, since Groovy also supports functional programming.
Be the first to like this
Login to see the comments