Object Functional Patterns

ObjectFunctionalPatterns describe ways to adapt features and strategies usually found in FunctionalProgrammingLanguages for use in ObjectOrientedProgramming. Some of these are ProtoPatterns, but many are not. ThomasKuehne first brought these concepts to Wiki with his FunctionalPatternSystemForObjectOrientedDesign and many patterns in this language originate from his PhD thesis which is a book by the same name.

FunctorObject shows how to treat functions as first class objects. This is useful for implementing HigherOrderFunctions in an ObjectOriented environment.

GenericFunction and GenericFunctionObject describe how to implement ExternalPolymorphism and MultipleDispatch -- features normally found only in FunctionalProgrammingLanguages. These mechanisms allow us to make verb based abstractions in addition to the noun based abstractions that ObjectOriented languages give us. When objects are used in these abstractions they become passive rather than active which gives us a wider range of expression.

FunctionCallObject is a ProtoPattern that describes how to treat the stack frame of a function call as a first class object it is very closely related to LazyObject. If FunctionCallObjects can be made to work then ContinuationsAndCoroutines can be used in an OO environment and can potentially reduce or eliminate the need for threads.

Programs can be made more efficient by delaying computations using LazyEvaluation and caching the results (see CallByNeed). LazyObjects are one way of doing this. LazyEvaluation has its problems though. In an world where state is mutable LazyEvaluation can be too lazy. Immutable ValueObjects and CommandQuerySeparation can be used to protect against aliasing and side-effects.

InternalIteration can make code easier to read and write. FunctorObjects enable their use, but they do have some limitations especially when it comes to flexibility. The TransfoldPattern shows how to InternalizeExternalIterators in order to simultaneously iterate over multiple collections.

The TranslatorPattern extends the concept of ExternalPolymorphism to objects and more importantly aggregates of objects. So that these aggregates can be used in new contexts without having to be re-opened and extended.

You can get a complete list of these patterns by going to CategoryObjectFunctionalPatterns and clicking on the title.

I wonder if ThomasKuehnes ValueObjectPattern? has any details that are missed on the ValueObject page. Similarly I wonder if there is any difference between his VoidValue? and our more familiar NullObject.

See FunctionalPatternSystemForObjectOrientedDesign, ObjectFunctionalImplementation.

See also ObjectFunctional
CategoryPatternLanguage CategoryFunctionalProgramming CategoryMultiparadigm

EditText of this page (last edited April 5, 2010) or FindPage with title or text search