Let me disagree to you with statement about benefits of OOP. It doesn't have any kind of benefit. All it has is a bunch of syntax sugar, period. If you see it as a benefit then I'm not entirely sure you're qualified to tell benefits of this kind of things.
That doesn't mean I don't use OOP though. I never said so. I just don't
abuse it; when situation calls for it, I employ some techniques I think are appropriate there. Like in my controls library, I use OOP approach to make it easy for users to handle the states, since Lua provides colon function call syntax anyway. If it wasn't, I'd still used this kind of approach, only I'd have to explicitly declare "self" argument. That's how you do that in C. Also, in C you would use underscore notation rather than dot/colon notation:
Code: Select all
library_class_function ( object, argument )
It doesn't makes much difference at all against using provided syntactical sugar.
Code: Select all
library.class.function ( object, argument )
-- OR
object:function ( argument )
The latter is shorter though, but having to type slightly less doesn't actually makes any difference if you think about it. You could easily achieve exactly the same result just by using
shorter names, so this argument doesn't makes sense. Besides, it's not like having to type extra 30% makes anywhat significant difference, since most the time you would think rather than type (and you would often think while you type). "Coding is easy part." The real thing here is that you don't have to know exactly which class object is to call it's function. On the other hand, you would exactly know what class it is
in advance before even calling this function, because you expect specifically defined behavior (if you weren't sure you'd implemented class check functons to
ensure), so this kind of arugment doesn't makes sense as well. This makes for a conclusion that the whole difference, basically, is having to type slightly less on the one hand, and the possibility of being confused about different classes different implementations of the same named function on the other hand. Not really a benefit, more like a tradeoff with arguable profits.