lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It is so because people tend to use OOP the "wrong" way.

Frankly, learning C and then Java, OOP always felt a bit strange to
me; sure it's a nice way to make types but if you look at the design
patterns of the Gang of Four you'll see that most of them patch a
"problem" in the language: lack of globals, lack of first-class
functions / closures, lack of multiple dispatch, lack of
instance-level polymorphism.

I believe that people tend to misuse extention and to use interfaces
has a solution for the lack of multiple inheritance. (I also believe
I'm not alone in this: either the creator or Java or C++ said that,
looking back, he'd leave inheritance of code out [citation needed]).

My opinion is that one should use intefaces to establish the contract
of the type ("I respond to these messages") and use delegation to
"extend" pre-existing functionality, rather than subtyping and face
something like the "Liskov Substitution Principle" (which is almost
philosophical).

That said, if one finds that competing OOP models is hindering
development, maybe one should consider an "has-a" relationship instead
(under the hood, in Lua, it's always delegation anyway).

On 3/31/10, Petite Abeille <petite.abeille@gmail.com> wrote:
>
> On Mar 31, 2010, at 7:22 PM, Aleirade wrote:
>
>> This works fine until I want to subclass a class made by someone else
>> using
>> my own OOP model which I already use extensively in my own code.
>
> Doctor, it hurts when I do this... :D
>
>