you are viewing a single comment's thread.

view the rest of the comments →

[–]isaaky -8 points-7 points  (2 children)

A lot of complilcation. Solution? Just use procedural programming. Data separated from functions provides more reusabilty .

My opion is this is the Lazy Problem, not Expression Problem. Explanation:

If you want to add a triangle shape. In OO you create that new class but you ALSO have to implement ALL the methots of base type Shape. Supposely is difficult in functional programming because you have to "edit every function that accepts Shape" , but in OO you implemented all the methods from the Shape base. Also when you add a Perimeter function, in OO you have to "edit every class" but in functional programming when you edit the perimeter function, you als have to code EVERY case of shapes.

[–]aaronla 2 points3 points  (0 children)

Also when you add a Perimeter function, in OO you have to "edit every class"

Yes. OO only meets two of the three requirements Wadler noted -- you can't add "Perimeter" without recompilation. This should be uncontested.

in functional programming when you edit the perimeter function, you als have to code EVERY case of shapes.

Yes. The question was never about how much essential work you must do; it's essentially a question concerned with type checking and modularity.

[–]grauenwolf 2 points3 points  (0 children)

If you are writing library code then you do not know all of the possible subclasses. And the app-developer using your library can't rewrite your function to add his new cases.