If there is some parameter flags that cause variations of behavior of a subroutine - clearly comment this at the parameter definition and down in the code where trhe different modes take action. (Im not talking about simple subroutines but ones hundreds and thousands of lines long that it may not be productive to have a variant copy customized for each 'mode'.)

Especially if the scope of the differences cause odd side-effects or have important limitations.

Document those (if not anything else) becase of the amount of the time/effort it takes to trace thru the code again to figure out what it does and once you find it (as when fixing other peoples poorly documemnted/commented code) it can save the effort or repeating the detailed logic tracing.

Anything with weird/atypical/convoluted behavior should get priority for comments if there is little time for any done systematically (its just a fact in the real world that you dont always have the resources to do a full commenting/documentation).

----

And when I make many such comments I make them very plainly stand out so that its hard to miss (indicating that the codes behavior is something to be wary of)

--------------------------------------------Ratings are Opinion, not Fact

If there is some parameter flags that cause variations of behavior of a subroutine - clearly comment this at the parameter definition and down in the code where trhe different modes take action. (Im not talking about simple subroutines but ones hundreds and thousands of lines long that it may not be productive to have a cariant copy customized for each 'mode'.)

I'm going to agree here, on the caveat that youl should avoid writing this kind of code as often as possible in the first place. Sometimes it's unavoidable, but it's a code smell that should be minimized. A function should ideally do one thing. It's not really one of those lofty architecture astronaut ideals 99% of the time either.

Here's my tip... define your goals ahead of time, both for yourself and for the project. If you're doing it to learn then take every chance to learn. Try out new approaches to various coding problems even if you're already comfortable of some other way of doing something. Having more tools at your disposal for the future is what learning is all about.

On the other hand, if your primary goal is to create an awesome game and to hell with everything beyond it, then do the opposite of the above. If you know a way to solve a problem, don't worry about whether or not its the best way or even necessarily a good way, provided it works and it does the job you wish it to do.

In reality, most projects are going to be somewhere between those two extremes. Learn how to balance the benefits of taking time out of your project to learn something new versus just powering through with what you have understanding that there might be better ways of doing things out there but knowingly declining them for now.

I'm working on a game! It's called "Spellbook Tactics". I'd love it if you checked it out, offered some feedback, etc. I am very excited about my progress thus far and confident about future progress as well!

For games, especially if you are designing, you are much less an engineer and much more a sculptor, constantly pushing and pulling things around, removing unneeded bits and adding extra bits. Plan for things to change,

Get a playable version as fast as possible. Even if it all gets thrown away.

Prototyping is a design step, a pre-production step.

Its going to help in planning and identifying what really needs to be implemented.

Design up front just enough to get a good idea of what you really need.

Implement the minimal amount.

Schedule the minimal amount.

Art and sound and nice assets can wait. Make things work first.

And the last thing is my personal law for programming. It might sound stupid but it helps in about a million ways.

Never write a function longer than 50 lines (including white space and comments). Decompose. make it fit on a single page.

Even when you are the single developer of a project write code as if it is intended for other people to use. You will be the other people when you look back at your code in 6 months time.

Side note:

For C++, I'd recommend reading C++ Coding Standards by Sutter and Alexandrescu. The table of contents
by itself is helpful, but the full book contains discussion like
reasoning and exceptions to the general rules. The only problem is that
it predates C++11.

I like this quote on the amazon link: "Short is better than long: Huge coding standards tend to be
ignored; short ones get read and used. Long Items tend to be skimmed;
short ones get read and used."

And then you release a 240 page counting book as a coding standards that's a brilliant way of contradicting yourself

the free online repository site I'm using has a built-in issue tracker

Which free online repository site are you using?

Didn't want to sound like I was advertising, nor stir up a Git vs. Hg firestorm, so I didn't name names, but I suppose there's no harm in saying Bitbucket. Github probably has similar features, but the deciding factor for me was Bitbucket's unlimited free account for those with a .edu email address. As a broke grad student, I couldn't turn that down.

Just to add to this for the benefit of other people reading this thread, I use unfuddle,com for source control on my personal projects. It allows totally free svn repositories to anyone but with the free account you can't have multiple users on projects. I don't know if they provide source control using software besides subversion.

Sorry, but if you've been using singleton's "instead of" globals then you have still been using globals during the past 8 years. A singleton isn't better than a global just because it's wrapped up in a fancy class, and using a singleton because "you need something like a global" is a terrible reason to use the pattern. You should use a singleton if you need a singleton; that is:

If there must only ever be one instance created. Note that this is different from only wanting or needing one instance -- if you only want or only need one instance then don't bother with additional code to enforce it and instead only create one -- the singleton is appropriate when it would be an error for there to be more than one instance.

If you need global access.

Unless you need both of those requirements the singleton is not the right pattern for your situation, and it's exceedingly rare to genuinely require that there must only be a single instance.

There is one other bullet:

- deferred allocation.

I also dont think single instance classes are all that rare. Of course you could design around the requirement.

It is also worth pointing out a few pro's about singletons. First off, the most nasty evil horrible stuff about singletons is mostly only applicable to C++. Singletons in Java or C# are nowhere near the landmine they are in C++.

Second, they are easy to grok. That's why you see them in use in a number of very successful game libraries. They may not make for the purest design, but they make for one that is generally easily comprehended. This is why you see singletons used in Moai, Cocos2D, Ogre3D, PlayStation Mobile, etc... etc... etc...

There's nothing about deferred allocation that requires a single instance or global access. You can have deferred allocation with a class that you can have multiple instances of. You can have deferred allocation with local or member variables.

There's nothing about deferred allocation that requires a single instance or global access. You can have deferred allocation with a class that you can have multiple instances of. You can have deferred allocation with local or member variables.

Yes, but it is a trait of the singleton. I am not saying there aren't other ways to accomplish the same thing, but it is one thing a singleton gives you.

No, it's not. Singleton is two things: single instance and global access. That's the definition. If you have those two things it's a singleton. If you don't then it's not. Some common implementations have deferred allocation, but you don't need a singleton to do it and a singleton doesn't require it. If you want deferred allocation there's no reason to go and restrict your deferred allocated class to a single instance and force it to have global access, which is exactly what you are saying to do if you're saying reach for a singleton when you need deferred allocation. Deferred allocation is orthogonal to both number of instances a class can have and scope of access. That's saying every time you need to use new (a deferred creation mechanism) you should have a singleton.

That's saying every time you need to use new (a deferred creation mechanism) you should have a singleton.

No, its not. Allocation and access are coupled with a singleton. If new was smart enough to not new an existing object, I would agree with you.

I am also not saying that if you want deferred allocation, use a singleton. I am saying a singleton provides that trait, nothing more. So, if you have a global object, that requires a single instance and you want to defer it's allocation until first access, a singleton provides this. I am not saying other data structures don't, nor that there aren't other ways to accomplish this.

Not part of the singleton definition. Allocation can happen before a singleton is first accessed and it would still be a singleton. And you can couple allocation and access for an object without bringing in either global access or single instances of the class.

I am also not saying that if you want deferred allocation, use a singleton.

Yes, you did! You added deferred allocation to jbadams list of times when you need a singleton.

I am saying a singleton provides that trait, nothing more.

No, it doesn't! A singleton is defined by two traits: single instance of a class and global access. Common implementation often have deferred allocation, but it's not a requirement. Ex: a Meyer's singleton can be constructed before first use.

So, if you have a global object, that requires a single instance and you want to defer it's allocation until first access, a singleton provides this.

Which is saying that if you want a singleton with deferred allocation, then you want any old singleton! You're confusing a common implementation detail of a pattern for part of that pattern.

I am also not saying that if you want deferred allocation, use a singleton.

Yes, you did! You added deferred allocation to jbadams list of times when you need a singleton.

Well that would be the crux of the disagreement between us. I read jbadams post as times you could use a singleton, not when you need one. In re-reading his post, I will admit outright, this was a mistake on my behalf.