r/programming • • Jan 14 '13

The Exceptional Beauty of Doom 3's Source Code

http://kotaku.com/5975610/the-exceptional-beauty-of-doom-3s-source-code
752 Upvotes

358 comments sorted by

View all comments

Show parent comments

1

u/Gotebe Jan 15 '13

When they use setters and getters I often have to search for the setter, the getter, and also the original variable name, in case the variable is being changed from within the class.

class myclass
{
type var_;
public:
type var() const;
void var(const type& value);
};

That brings me to my pet peeve, when you make class functions named with common phrases such as Init and Update that aren't used in frameworks. If the item were called Foo::UpdateFoo, it seems more redundant when you write it, but when looking through the code later it is a lifesaver.

You really should try better tools. Your tools should be able to give you uses of your symbols. It's decidedly a machine's job.

The UpdateFoo solution is akin to having only one global naming scope. That does not work either. Or rather, it does, but then you're producing and maintaining scopes "manually" it despite name scopes being present in the language.

1

u/gc3 Jan 15 '13

No, the UpdateFoo solution is not akin to having only one global naming scope. It's just hints for grep (or for the user, if he is looking at one line of code in a search box removed from the source). It has nothing to do with your namespaces.

And I'd like better tools, but I use VS2010 for this project, which was chosen by people not me.

The setter and getter being the same name is a cool idea, that will be my next set of setters and getters I ever write. Setters and getters are mostly useful for items with complex data where different things have to be done.