POV-Ray : Newsgroups : povray.off-topic : C++ structuring help.... : Re: C++ structuring help.... Server Time
10 Oct 2024 17:17:52 EDT (-0400)
  Re: C++ structuring help....  
From: Warp
Date: 20 Mar 2008 19:00:03
Message: <47e2fa83@news.povray.org>
stbenge <stb### [at] hotmailcom> wrote:
> A simple (tile based) level editor is my current project. Already, I 
> have about two dozen global variables. It's getting messy, and I'm 
> having to rewrite code to handle, say, foreground tile editing as 
> opposed to background tile editing.

  High-quality object-oriented design is far, far from trivial to do.
It requires years of OOD and OO programming experience, and even then
it usually requires several iterations of design-use-redesign.

  Making a good, encapsulated, abstract, flexible and reusable graphical
editor is a rather difficult tasks of OOD in general (regardless of the
programming language used) and C++ programming in particular. I know this
because I have been working on exactly such a thing as my payjob.

  You are on the right track, though: Global variables should and can
be avoided (there are very few exceptions to this rule, of which eg.
std::cout is a good example (I consider std::cout to be a "global" variable
even though it's inside a namespace), where practicality compensates
globality more than enough), and clean abstract designs should be preferred.

-- 
                                                          - Warp


Post a reply to this message

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