[linux-l] Re: SW-Design / Modules vs. Objects/Classes (Re: Adaptor-Pattern mit Ocaml's Module System
Ivan Villanueva
iv at artificialidea.com
Sa Okt 22 11:52:24 CEST 2005
Hi,
> vielleicht interessant für die hier immer wieder auftauchenden
> Diskussionen um SW-Design...
>
> ...aus einem Paper (icfp99.ps) von Xavier Leroy:
>
> =======================================================================
>
> Myth: OO programs are easier to extend
>
>
> Consider a type of "things" with several kinds of things and
> several operations over things.
>
>
> | FP-approach: | OO-approach:
> | |
> | One function per | One class per kind of
> | operation, defined by | things, one method
> | pattern matching on | per operation
> | things |
> ---------------|-------------------------|-------------------------
> adding a new | Must edit all | Add one class, other
> kind of thing | functions, adding a | classes unchanged
> | new case to every |
> | pattern matching |
> ---------------|-------------------------|-------------------------
> adding a new | add one function, | Must edit all classes,
> operation over | other functions | adding a new method
> things | unchanged | to every class
> ---------------|-------------------------|-------------------------
>
> =======================================================================
>
> Schön ist's, wenn eine Sprache beide Möglichkeiten unterstützt. :)
In Java für die zweite Zeile könnte man den Decorator Pattern benutzen, um nicht
alle Klassen ändern zu müssen. Oder mit reflexion einfach eine neue Methode
zuzufügen.
--
Ivan F. Villanueva B.
The dream of intelligent machines: www.artificialidea.com
Encrypted mail preferred.
GPG Key Id: 3FDBF85F 2004-10-18 Ivan-Fernando Villanueva Barrio
Mehr Informationen über die Mailingliste linux-l