Wednesday, November 23, 2011

Expression Problem

Expression Problem: "The 'ExpressionProblem' manifests when you wish to 'extend' the set of objects or functions.
If you want to add a 'triangle' shape:
the ObjectOrientedProgramming approach makes it easy (because you can simply create a new class)
but FunctionalProgramming makes it diffcult (because you'll need to edit every function that accepts a 'Shape' parameter, including 'area')
OTOH, if you want add a 'perimeter' function:
FunctionalProgramming makes it easy (simply add a new function 'perimeter')
while ObjectOrientedProgramming makes it difficult (because you'll need to edit every class to add 'perimeter()' to the interface).
"

'via Blog this'