[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua and composition
- From: Martin <eden_martin_fuhrspam@...>
- Date: Sat, 4 Mar 2017 13:13:46 -0800
On 03/03/2017 11:32 PM, Petri Häkkinen wrote:
> I'm trying to come up with an example where the OOP style is more cleaner (could you give an example?)..
> e.g. in my mind the syntactic difference between the two styles in the following case is irrelevant in practice:
>
> obj:draw_rectangle(x, y, w, h)
> vs.
> canvas_draw_rectangle(obj, x, y, w, h)
I think more OO-variant is when both <canvas> and <obj> are
classes and actual coordinates provided by some class for screen
rectangle:
canvas:draw_rectangle(obj:get_rectangle())
Alternatively, <obj> may store canvas and draw itself anything
it wish and canvas methods can:
obj:draw()
where draw() is like self.canvas:draw_rectangle(self:get_rectangle())
-- Martin