lua-users home
lua-l archive

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


Mike Pall <mikelu-1104 <at> mike.de> writes:

> <rant>
> However I strongly suggest to resist the initial impulse to build
> up a complex class system for Lua. Inheritance is overrated, anyway.
> 
> It seems to be a common reflex of programmers coming from other
> languages to build up their dream of a class system for Lua as
> their first task. Learning how to actually write good code in Lua
> is skipped of course, because the language looks so easy, right?
> 
> Many months later, they still have no application to speak of, but
> an overly complex, slow and entirely useless framework that's
> quickly abandoned right after blogging how horrible their whole
> Lua experience was. 
> </rant>
> 
> --Mike

I am coming from a C++ backgound and I am very intersted in learning how to
write good code in Lua. 
At the moment I am reading PIL and I am amost done with the first section (I
still need to read the chapters on coroutines and weak tables).
I also had a look at the deprecated features for 5.2 to get an indea of what is
not considered best practice any more :)

I welcome any suggestion on this point!

Btw, Scott Meyers suggestion (in his Effetive C++ and More Effective C++) is to
have concrete classes only as leafs in inheritance hierarchies (the rest would
be abstract). 
That is to say to use inheritance most of the time as "interface inheritance"
and not as "implementation inheritance". This is also in line with his
suggestion to consider composition instead of inheritance.
In dynamic languages this means to use "inheritance" only sparsely :P

That said I use object oriented design in most of my code, as in my experience
it results in mantainable and scalable code.



Cheers,
KR