POV-Ray : Newsgroups : povray.off-topic : Generics annoyance : Re: Generics annoyance Server Time
4 Sep 2024 13:19:16 EDT (-0400)
  Re: Generics annoyance  
From: Warp
Date: 13 Apr 2010 16:46:40
Message: <4bc4d82f@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Darren New wrote:

> > Actually, I think that clued me in a bit. They *are* all of type 
> > "object". ;-)
> > 
> > So I could just have a list of objects, and when I get an update, 
> > (dynamic)-cast each element to a IUpdatable and invoke that if it works; 
> > when I get a draw, cast each to an IDrawable and invoke that if it 
> > works, etc.
> > 
> > Ugly, but it'll do the trick, I think.

> Ah yes, ye olde "upcast everything to Object" antipattern. :-D

  Yeah, that kind of OO programming has always been considered bad design.

  If C# offered multiple inheritance (I don't know if it does), then you
could inherit all the objects you are using from GameComponent and your
own "base class", which is what the container then contains.

  (Of course this solution wouldn't help if you have to store objects
which have been eg. instantiated by the library framework itself because
those would not have been inherited from your "base class".)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.