Functional Programming at Work in Object-Oriented Programming
Ph. Narbel, LaBRI, University of Bordeaux 1, France |
 |
REFEREED
ARTICLE

PDF Version |
Abstract
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.
Note: Due to the typographical sophistication of this article, no HTML version is available. Please use the PDF version.
About the author
Ph. Narbel is associate professor in computer science at Bordeaux University,
France. He can be reached at narbel at labri.fr.
|
Ph. Narbel: "Functional Programming at Work in Object-Oriented Programming", in Journal of Object Technology, vol. 8, no. 6, September-October 2009, pp. 181-209 http://www.jot.fm/issues/issue_2009_09/article5/
|