(I tried to keep this as non-technical in vocabulary as possible so that non-programmers also have the ability to read it, after all, there are enough "In depth" discussions of this code, plus my only experience with C is C#, not C++ which is what Doom 3's code consists of)
So, as some of you are aware, id released id Tech 4's (Also commonly referred to as the Doom 3 Engine) source code a while back. I've been hearing from everybody about how amazingly beautiful it is for source code, easy to parse, sparing use of comments, and all that, so I did finally take a look at it. id Tech 4 is really useful, and has been used in many other newer games, the engine is so versatile you probably can't tell they're based on such an old engine.
And I must say, the rumors are true, Doom 3's Source code is perhaps the most beautiful code I've ever seen. For a game about demons, this code seems heaven sent. Seriously, even expert programmers have things to learn from Doom 3's code, it's that great.
It's so neat and easy to read for coders and easy to parse that it makes Unreal Engine cry itself to sleep.
Let's go in more detail, even though many people have already done so before me. One of the first thing many will notice is that Doom 3 never skips the brace brackets, even when they could. This is a very good thing because if you do skip Brace brackets where possible your code looks ugly, to be frank. It's much easier to read if you use the brackets, trust me.
Another great thing many have pointed out is it's unique/uncommon use of horizontal space. This is good because it allows more chunks of code to fit onto the same screen than if they used the most common method of spacing. But I kid you, I mean, it doesn't really matter if you use the conventional method and thus people can't read your code.
Comments are used rarely, which is good because coders usually use a whole ton of them where unnecessary, what angers me most is perhaps the common method where coders put a comment even when the name of the line of code tells you what you need to know. If you can't tell what code does by it's name, then you've named in incorrectly. This is especially troublesome when you have a programmer working on a project who incorrectly names lines and then quits before the project is finished, this exponentially increases the amount of time it will take for any replacement coder to decipher what the hell each line of code is supposed to do.
Another good thing is that in Doom 3, each function does just that, a single function, this makes it much easier to go back and change things. Companies who don't do this sometimes end up releasing games/ports of games that are broken beyond repair. Like, say, making the game so that it freezes instantly if it tries to use more than a set amount of RAM and making it so common and horrible that the community had to fix it, which is quite frankly the developers' job, and building this nifty little feature into the game engine itself, even if your previous great games didn't have such a bug.
Games on id Tech 4 don't have this issue because all files are the same type, and all the functions perform only one action. This in combination means that parsing is easy and adjusting the code if a problem arises is an easy task. Something that isn't possible if the functions all perform complicated tasks with different types of files, if they are so clustered, it makes it almost impossible to correct any errors without creating new ones. Doom 3's Engine does not have this problem.
I love it, it has so much to teach about how to format code professionally and easily. It is incredibly easy to build upon this engine and get a game licensed with it and it's well worth it because the engine has features that can compete with today's games. The only reason Unreal Engine 2 really took the glory away from id Tech 4 is that id did not want to release the engine's source code before they released Doom 3 itself. And that's when Unreal 2 Engine stole the spotlight, directly before Doom 3's release.
An engine like this is built with great code and can be used to create greatly games. Even for those who don't work with programming games (Such as myself) it taught me a lot about easier methods to code.
If you want to see this glorious code for yourself, as it does have a lot to teach about proper programming formatting, and once more, it's the most beautiful code that has ever existed, plus it's free, then Click Here to download it in it's entirety. It's well worth it whether you're a beginner in programming, just curious about code and not looking to program, or an expert programmer.