Mat Noguchi turned me on to a talk by James Coplien. The purple book ("Advanced Styles and Idioms in C++") used to be my bible, so I checked it out - o
I feel like the chef in T. C. Boyle's "Sorry Fugu" when he gets Willa Frank to say something nice about him.
Of course, I have to agree that everything he says in Spidey 2 is crap is crap. Even the missions, which I made some of. What can I say? Movie license, strict release date, excuses, excuses. At least we got something right:
So Bryan says you can't have globals if you have a multicore architecture.
Sorry, in the last post, instead of saying "you don't want any global accessed from anywhere" what I meant was "you don't want every global accessed from everywhere." You do want some globals accessed from somewhere. It's going to be really hard to convince me that Mat Noguchi's proliferation of pointers is a good thing, unless they're smart or shared.
Ok, I need to refine. I don't like Gang of Four singletons either; I tried them way back when on Draconus and never wanted to use them again because of order-of-initialization surprises. But I do like the syntactic sweetness of static Inst() accessing a static member, as long as we control initialization order ourselves, as Noel Llopis suggests. That's why I said "variation of a popular singleton pattern" - key word being variation, don't use it as written.
One of the first things they taught me in my college Pascal class (I already knew some Pascal, but had to take it for the credit...on the bright side, that's where I learnt about pointers and recursion, so it was worth it...) was that global variables are bad. And in most cases this is true, but I think it's easy to take this philosophy too far.
Couple questions answered about the last post:
One of the guys on our project wanted to change the way sound folders are organized, and I realized I have fairly strong feelings about the subject. Most of this is just curmudgeonly ranting, it is not Truth, but still:
My experience is keeping folder hierarchies flattish cuts down on minor daily annoyances, both with source control and navigating: say you’re editing the raw content data in one folder, then you go to save, so you have to click up, up, then down, down to get to the proper destination directory; whereas scrolling through a long list of files usually just requires a keypress or three.
To make this work, when using Explorer, everyone will want to do View->Details, otherwise sure, the screenfuls of icons would be overwhelming.
Keeping the raw content separate from the cooked (content you're actually going to ship in the distribution) is important, to simplify not just the authoring/final build process but the process of giving publishers, associates, marketers builds.
One idea that occurs to people frequently is to use the directory structure to describe the files. So instead of zombieAttack.qrx and zombieIdle.qrx you'd have a \zombie folder that contains Attack.qrx and Idle.qrx. This is appealing at first but it's nice to know if you've accidentally dragged the zombie attack sound into the yeti folder. And if the code can assume that every sound name is unique that can gives you an advantage - you can use the asset name as a unique ID. (I don't believe there's any reason any more to have an asset manager that builds .h files with asset codes baked into them - maybe I'll post on how we get around that someday.)
It's not *that* hard to rearrange your hierarchy later (though source control can make it harder) so don't fix a theoretical problem now ("This might get messy"); wait for it to become an actual problem.
When would I start subdividing a folder? When it hits around 500 files, or when all of the files of a subcategory no longer fit in a couple of pagedowns. That is, once you've got enough zombie_xxx files that it isn't just a keypress to find the one you want.
One last thing: I don't use spaces in file and folder names, I use underscores or intercaps. Using the command line to do things with files has become vanishingly rare, but typing in those quotes to find a file with a space in the name is still annoying on those rare cases where I need to do it.
Curmudgeonly ranting over.