Design Pattern for Reusing Immutable Methods in Object-Oriented Languages. Flageol, W., Gu�h�neuc, Y., Badri, M., & Monnier, S. In Proceedings of the 28<sup>th</sup> European Conference on Pattern Languages of Programs (EuroPLoP), pages 1–9, July, 2023. ACM Press. 9 pages.
Design Pattern for Reusing Immutable Methods in Object-Oriented Languages [pdf]Paper  abstract   bibtex   
\textbfContext. Features and styles inspired by functional programming have grown in popularity in the world of object-oriented programming. Immutability is a core concept of functional programming, which brings advantages to software development. However, introducing immutability in object-oriented programming presents some challenges. \textbfProblem. One of these challenges is method overriding. When inheriting non-destructive mutators (methods used on immutable objects which return a new object instead of modifying the receiver), a naive approach generates code duplication and has scalability issues. \textbfContribution. We analyse an example of this overriding problem and propose a solution in a new design pattern based on the factory method pattern. We also discuss the advantages and limitations of this pattern, as well as implementations in Clojure, Java, and Kotlin. We also identify and discuss the language features that mostly affect the implementation of this pattern. \textbfConclusion. Our proposed design pattern helps mitigate some of the code duplication and scalability problems of a naive approach. However, the inclusion of a functional updating language feature is required to completely remove the scalability issues.

Downloads: 0