This paper is a synthesis about why and how some functional programming (FP) can be helpful from a program design point-of-view within mainstream object-oriented programming (OOP). We first introduce criteria to ensure that FP-oriented features give an effective functional/method granularity design level within OOP. Next, we list up and discuss the general techniques and design consequences of having such FP capabilities in OOP, i.e. code abstraction/factoring at a function level, generic iterator/loop implementations, operation compositions, sequence comprehensions, partial application and currying, reduction of the number of class definitions, name abstractions, and function-based structural compatibilities. We also stress some of the difficulties of blending FP constructs with OOP, by pointing out potential problems related to design granularity mismatch, architecture non-uniformity and datatype incoherences. Several classic OOP design patterns are analyzed, since FP techniques make alternative implementations manageable: basic cases like Strategies, Commands and Observers, but also Proxies (using functional-based evaluation control) and Visitors (using functional data-driven programming). This synthesis is illustrated with C# 3.0 which offers effective FP-oriented features - based on delegates -, but also by using comparisons with other cross-paradigm languages. © JOT, 2009.
CITATION STYLE
Narbel, P. (2009). Functional programming at work in object-oriented programming. Journal of Object Technology, 8(6), 181–209. https://doi.org/10.5381/jot.2009.8.6.a5
Mendeley helps you to discover research relevant for your work.