[Oberon] FPGA - Simple OOP example

Jan de Kruyf jan.de.kruyf at gmail.com
Wed Aug 15 09:02:47 CEST 2018


Thanks for that  Jörg .
I thought you people were all on holiday so I tried to help a bit. But you
are the expert.

j.


On Tue, Aug 14, 2018 at 10:39 PM, Jörg <joerg.straube at iaeth.ch> wrote:

> Tomas
>
> As you said in one of your previous mails: there are different ways to do
> OOP in Oberon. My recommendation to separate data and methods (and collect
> all methods in an own RECORD) has basically two reasons:
>
> 1) Space. It’s perhaps not so obvious in your Term example, but if you
> have objects like e.g. Figures, Circles, Rectangles ... you might have a
> large amount of methods (Draw, Fill, Rotate, Delete, Move, Shrink,
> Recolor...) . Let’s assume you prgram a game and your background landscape
> is composed of 1000s of Figures. And every Figure does not only store its
> data like radius and color but also all methods as well, the space in
> memory for all those objects is quite large. After all, keep in mind all
> the methods in all Figures point to the same procedures it‘s just a waste
> of memory to store the methods separately again and again in every figure.
>
> 2) Consistency. If you have a Figure like a Circle, there might be 100
> different instances of circles. The local data that is different per circle
> (Big, small, red, blue, filled...) is stored and varies per instance. But
> you expect that all circles behave the same. So it makes sense to collect
> the behaviour (=its methods) of the object „Circle“ in an own RECORD. And
> let all different instances of object Circle point to the one same
> behaviour.
>
> br, Jörg
>
> > Am 14.08.2018 um 19:48 schrieb Tomas Kral <thomas.kral at email.cz>:
> >
> > Jan, Joerg,
> >
> > Thank you, recoding my example now. Just curious, is there a specific
> > reason to keep object's data from its methods?
> >
> > --
> > Tomas Kral <thomas.kral at email.cz>
> > --
> > Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> > https://lists.inf.ethz.ch/mailman/listinfo/oberon
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20180815/dba7550d/attachment.html>


More information about the Oberon mailing list