POV-Ray : Newsgroups : povray.off-topic : C++ structuring help.... : Re: C++ structuring help.... Server Time
10 Oct 2024 17:18:10 EDT (-0400)
  Re: C++ structuring help....  
From: Warp
Date: 22 Mar 2008 13:58:11
Message: <47e556c0@news.povray.org>
John VanSickle <evi### [at] hotmailcom> wrote:
> The easiest way to get rid of the globals is to declare a class which 
> has some static members in it:

  IMO that only masks the problem, it doesn't solve it.

  If you find yourself using tons of global variables that's usually a
sign of an overall design flaw in your program. Moving the globals inside
a namespace or a class doesn't really solve the underlying design problem.

  As I have already mentioned, not all global variables are bad, and it's
not like you would have to avoid them like the plague. However, usually
the vast majority of global variables, especially if you find yourself
writing tons of them, are a sign of bad design.
  It's usually a sign that you are not using proper encapsulation and
proper abstraction, which are key concepts in creating high-quality reusable
and flexible code.

  Note that the problem with global variables is *not* exclusively that
the garbage the global namespace. That's actually the smallest of the
problems involved. That's why simply masking this one problem isn't really
the answer to the bigger design problems.

  With small projects good OOD doesn't really matter. However, the larger
the project, the more it becomes really useful.

-- 
                                                          - Warp


Post a reply to this message

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