[Haskell-cafe] How to fulfill the "code-reuse" destiny of OOP?

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Sat Oct 31 08:03:18 EDT 2009


After all, I never think OO as an oppsite way to all other things. The
idea is so general that if you say I cannot use it in Haskell at all,
that would make me feel weird. The only difference between languages
is, some are easy to be in OO style, some are not.

2009/10/31 Andrew Coppin <andrewcoppin at btinternet.com>:
> Rogan Creswick wrote:
>> On Thu, Oct 29, 2009 at 6:54 PM, Magicloud Magiclouds
>> <magicloud.magiclouds at gmail.com> wrote:
>>
>>>  My concern here is about the data member inheriting. In OOP, when I
>>> inherit a class, I also got the members of it. But in haskell, how to
>>> inherit a "data"?
>>>
>>
>> In my experience (almost entirely with Java), it is usually a bad idea
>> to inherit from a class in order to reuse data storage that the parent
>> class provides.  Encapsulation (or a decorator, if you prefer) is
>> often a safer choice.
>
> ...otherwise phrased in OO circles as "people over-use inheritance and
> under-use collaboration".
>
> That said, I'm sure I won't be the first person here to say that
> generally, if you want to write a Haskell program, you should forget all
> about OOP and figure out how to structure it to make the best use of
> Haskell. It's a very different approach to program construction, and it
> requires a different way of thinking.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
竹密岂妨流水过
山高哪阻野云飞


More information about the Haskell-Cafe mailing list