J
JoeC
werasm said:Cut-and-pasting is bad. When things need to change fast, they tend to
fall apart if cut-and-paste stile programming were used. Get into the
habit of avoiding cut and pasting at all costs - serious (even forget
the key sequence, if need be).
Yeh, I know that cut and paste is bad but I was trying to make the
point of how somthing simple could be done better. One of the reasons
why I try to avoid longer names is a basic typing errors. Worse if I
use names that are too close and put the wrong name in. It happens in
other things I do.
As far as const go, this is a little
rule I follow myself. If the value needs to be part of my public
interface, or if it needs to be used in the class definition, then I
use an anonymous enumerated type:
example:
class X
{
//...
enum {Sz = 20 };
char array_[Sz];
};
I don't realy use enum lists much, I think I used them one or two
times. I have seen them in books and how to do it but have never realy
been shown the value for writing better programs. In my current work I
can't see where they would improve my code.
If on the other hand, the value is not required as part of the
definition, I use enumerators in my source file within anonymous
namespace (or static consts). The value of static consts can be
specified at the definition (during initialisation).
You lost me here. I have used static const where I need to but mostly
I am trying to take small steps to improve my code. Programming is
just a bunch of small steps.
[snip]
Most of the above is more about graphics, and less about C++
specifically, I therefore cannot comment, other than what has already
been said.
Thanks, I my graphics are not the focus of what I am doing but they
serve their purpose.