quote:Original post by Kylotan
But in the first example, if you change how you draw anything, you have to modify all the classes that do any rendering.
So both ways have some positives and negatives. Personally I go for the 2nd way, because I believe that individual objects shouldn''t need to know anything about rendering.
I believe that the way to make this completely OO would be use a base class for everything that needs to be rendered, which all of the other rendered classes are derived from.
For example:
class CRenderedObject{public: virtual void Render();};class CPuzzle : public CRenderedObject{public: virtual void Render(); //virtual in case you want to derive from this class later};class CMenu : public CRenderedObject{public: virtual void Render();};
Therefore if you have any rendering code that is shared between CPuzzle and CMenu you can just call CRenderedObject::Render().
void CPuzzle::Render(){ CRenderedObject::Render(); //class specific rendering code here}
I personally wouldn''t go quite so OO just for something simple like this, it looks a lot like MFC and I would only use it in a complex polymorphic class system with 100''s of classes. I think that your two examples would be fine for 99% of apps.
Comments?