Software development in todays world

I posted my views in another forum so I will crosslink so you guys can read and comment on the opinions of myself and others.

The guys responding have varying opinions on what should occur. It would be nice of you guys to tell me your opinions on things such as “self commenting” code.

http://www.beyond3d.com/forum/viewtopic.php?t=19845

My opinion on self-commenting code: it’s bollocks.
In fact, I believe it’s one of the 7 excuses of highy lazy people.

Don’t get me wrong, though.
I make my code as readable as possible, more so than almost anyone I know. 8)
I keep my methods small (strive for < 1 screen).
I almost never use abbreviations for names.
I often use really long names that give the full meaning e.g. originalXScaleFactor as opposed to xScale1
I think hard about what I name my methods to make sure they read aloud and make sense (e.g. my logger has a “willLog” method, so you can write logger.willLog(level)).

But no matter how good my code reads, I always comment anything longer than a few lines.
The main reason is that you cannot read code.
You can look at the code, think about it in your head and “translate” it, per se, an then you know what it’s doing.
But you always have to translate and this is a time-consuming process.
Comments, on the other hand, need no translation.
They tell you exactly what the code is doing, so you can know by reading one or two lines of English (very quick!).
Alternativey, you can translate ten lines of code in your head, which isn’t fast at all, and also requires your brain to work harder.

If you write “readable” code, then comments aren’t necessary.
However, they make maintenance and skimming a whole lot quicker, which makes the code “better”, in the sense that it is much easier to understand.

[quote]I posted my views in another forum so I will crosslink so you guys can read and comment on the opinions of myself and others.
[/quote]
Hmm. You need to think a bit more about how to do this kind of thing before doing it. Either everyone has to register for an extra account elsewhere, or you get two conversations in parallel, which is REALLY confusing for the people that try to be in both :). Only really works if the other forum is non-registration…

As to the rest, it doesn’t seem to be covering anything contentious or deep or interesting yet; you should probably do some digging around the JGO forums because IIRC there were a couple of conversations that went much further.

Nice article on “the uses of final”; I liked that :).

I got it off the Javalobby newsletter.
It’s extremely helpful and keeps me up to date.

My argument was really comparing people like John Carmack against everyone else.

People are lazy these days and don’t follow any design patterns when writing code, except for John Carmack.
The reason John Carmack is well renowned is because he’s a master coder.

What I’m trying to say is that John Carmack is such a good coder is because he follows a design pattern when developing ID’s engines.

It’s not just John Carmack either, other coders at ID software wrote Doom 3 as well. Check out the source.

ID coders have done an extremely well job at making code as readable as a picture story book.

I am a big advocate of design patterns as well.

In my day job (chief architect in a software company), I won’t hire anyone that doesn’t understand UML. It is so much more efficient to communicate with patterns then vague descriptions. The first question I ask during interviews is usually: “Have you used UML before?”

That said, all code should also be commented. Design patterns convey the architecture of a solution, but not the true implementation details. As they say…the devil is in the details.

BTW: John Carmack is my hero :smiley:

Short of downloading the doom3 sdk. Do you have any links to what his coding stlye is? Or a description of his methodology? googling for John Carmack gets quite a few results…

Cheers,
Dan.

I worked with someone that declared all methods final to prevent accidentaly overiding methods. I didn’t know this at start, and was a bit confused when I needed to extend one of his classes.

I’ve had a look at some of the Quake1 and Quake3 code. Don’t know if there were and great design patterns or not, but the code didn’t look that great.

[quote]Don’t know if there were and great design patterns or not, but the code didn’t look that great.
[/quote]
Of course it didn’t; he uses C/C++ ;D

He/team have created a set of classes the represent objects.

He’s library while large isn’t anywhere near the size of Valve’s HL2 library(download SDK to check it out).

The actual objects themselves are created during runtime when they are loaded into the parser and get parsed into the classes themselves.

All modifications to weapons, maps, etc… are done through scripts.

About JC’s coding style, I have no idea. I just looked at the SDK and said, “Hmmm, Carmack’s done a lot of work.”. :lol:

Doesn’t mean JC did all of that because AFAIK JC coded the engine and that code isn’t available.
Technically the JC stuff I spew is for pure obsession and laughter.

I don’t believe JC coded the game library at all, the tools on the other hand(called idLib under D3 SDK) is most likely JC’s.

The only thing at the top of all the files is “// Copyright © 2004 Id Software, Inc.
//”.

Makes it hard to say who had done what.
I’m pretty sure JC had some involvement in those tools, if not all of it could be his.

[quote]Short of downloading the doom3 sdk. Do you have any links to what his coding stlye is? Or a description of his methodology? googling for John Carmack gets quite a few results…

Cheers,
Dan.
[/quote]

JC isn’t my hero because of his design pattern use, but because he is a master programmer. He’s a one man army.

He started out much like the people on these forums. Creating games while working another job. He’s old-school indy. Now, he is also one of the most influential programmers in the world. When he speaks on 3D and 3D hardware everyone from the retailers, manufacturers and stock markets listen. He is a big part of the power we have for gaming today. He was also one of the saviors of Open GL during M$'s bid to try and squish it in the 90’s.

Our Java toys such as JOGL and LWJGL likely wouldn’t exist today without him and some other elite programmers having fought to keep OGL alive.

All that, and he thought about using Java as the script language in Q3, but felt it was a bit to immature at the time…which it was. Doom 3 scripting is a kind of mesh between C++/Java/entity scripting

[quote]About JC’s coding style, I have no idea. I just looked at the SDK and said, “Hmmm, Carmack’s done a lot of work.”. :lol:
[/quote]
Doom 3 was his first real C++ project. Given the outcome (engine/programming quality, not the game itself), you can assume a lot about his programming skills.

What interests me is to see how his move to object orientation is going to affect any future engine(s). A potential boost in production speed may also help Java prove its advantages.

[quote]About JC’s coding style, I have no idea. I just looked at the SDK and said, “Hmmm, Carmack’s done a lot of work.”. :lol:
[/quote]
I haven’t seen any doom 3 sources, but I remember the Quake 2’s and quake 3’s ones… It was so ugly… Totally unreadable. A lot of functions that only call another function which calls another function and so on…

Dunno about you, but I hate this coding style…

Anyway JC is surely one of the (or the ?) best game programmer out there. He is a “team” himself…

Chman

JC is famous for being a poor programmer in terms of bad style and lack of planning, but producing great games and finding low-level tricks so that he gets the reuslts (which is what matters to make money).

That he has changed is a reflection more upon how right all of us OOP-touting, “design is essential”, “plan before you code” advocates have always been than upon his abilities.

That he survived whilst not using the modern techniques that were available to him says a lot about his low-level skills and speed of coding.

But he’s still famous for being crap. Took him many yeasr to learn how to write decent networking code, for instance.

Attacking my hero? :o I must defend him!

[quote]But he’s still famous for being crap.
[/quote]
He is famous because he is a master programmer, not a crap programmer. Are you talking about the same John Carmack?

How many graphics algorithms do YOU have named after you? “Carmack’s Reverse” is the current best algo for real time shadows in games and “Surface caching” (another Carmack creation) is the algo that made Quake possible at a time when it was generally considered impossible on the hardware of the day.

His algorithms aren’t ugly, they are complex. Know the code and you will know the difference. His code is designed for speed, not pretty and is usually tackling many considerations at the same time. That makes it very fast, but very complex. He was the lone coder on the engines for much of it, so he didn’t worry about comments, he didn’t need them. Fast code…I mean REALLY fast code is often not the prettiest stuff to read. But it is often far more elegant then code that can be easily read by 6th graders.

[quote]Took him many yeasr to learn how to write decent networking code, for instance.
[/quote]
Oh do you mean the stuff he built into those engines he sold that have been used by dozens of major game companies for most of the top real-time multiplayer titles created in the last 10 years which is still considered the standard and benchmark today and defined the algorithm for everyone else? Oh THAT bad networking code… 8)

Creating fast code is slowly becoming less relevant in todays world and it’s not because computers will become faster.

JIT compilers will continue to improve beyond the efficiency of todays JIT compilers.

It’s just good discipline to write readable, maintainable, flexible code that is also well commented.

END - OF - STORY.

Sooner or later you will get caught going back to some neat piece of work and wondering…“now did I do that for this reason or was it that?” , all because you were too *$&#ing lazy to spend the time to save some time writing a line or two to clarify your thinking:-)

God forbid (or allah, yawah etc etc ) that someone else may have to work on it…

On Design Patterns, oop and other things the following are an interesting read (snipped from DevX mail - you may have to copy the links if they get cut by the forum):

THANKS, GANG! DEVELOPERS TALK FRANKLY ABOUT A DECADE OF “DESIGN PATTERNS” by Glen Kunene, Senior Editor A decade later, the Gang of Four’s “Design Patterns” is still a top seller and a “must read” for students and professionals. To celebrate its success, we asked programming professionals to tell us how this seminal work has influenced them. Some of their answers surprised us.
http://nl.internet.com/ct.html?rtr=on&s=1,1ckp,1,j6ek,eax9,lqnj,m494

OOP IS MUCH BETTER IN THEORY THAN IN PRACTICE
by Richard Mansfield
Think object-orient programming (OOP) is the only way to go? You poor, misguided soul. Richard Mansfield contends that OOP is just the latest in a history of ideas that sound good in theory but are clumsy in practice.
http://nl.internet.com/ct.html?rtr=on&s=1,1ckp,1,8ekt,fuf,lqnj,m494

Richard Mansfield is a dinasaur. He was a dinasaur 10 years ago, and 10 years ago people were saying the same thing about OOP.

Some people just don’t get it, plain and simple.

If he thinks the only successful application of OOP is reallly GUI’s he is completely out of touch.

I have been doing OOP since around 1988 getting close to 20 years now and I have seen it succeed far more then I have seen it fail. As I am sure most peple have.

I am not an OOP zealot, it’s a tool. Programming paradigms are like different types of brushes in the hands of artists. Most paradigms will work for most situations, it really up to the artist though.

If Mr. Mansfield still hasn’t figured out how to use it in all this time (he has been spewing forth crap since the 80’s)…then I think that says more about him then it does about OOP. :wink:

[quote]He is famous because he is a master programmer, not a crap programmer. Are you talking about the same John Carmack?
[/quote]
I must agree with Blah^3. The Quake game code is total rubbish, horribly disorganized. I’m not sure how muchof it is Carmack’s though. He was mainly doing the engine. Carmack is an OK programmer, perhaps with bad programming practices and style. I think the media coverage that id gets in terms of a small team making it big, blow his abilities out of proportion.

He is primarily “heroic” because of timing. He took a small team to great success because he came up with a 3D engine that performed very well for it’s day. Other people were doing similar things around the same time, but they didn’t get the fame of id because they didn’t release a massively popular product. I was at university at the time and knew of a few student projects that were doing similar things with 3D. For example this.

Think of the number of people on this very forum that have coded their own 3D engines.

[quote]How many graphics algorithms do YOU have named after you? “Carmack’s Reverse” is the current best algo for real time shadows in games and “Surface caching” (another Carmack creation) is the algo that made Quake possible at a time when it was generally considered impossible on the hardware of the day.
[/quote]
Others don’t get the media coverage, that’s all.

[quote]His algorithms aren’t ugly, they are complex.
[/quote]
His code is ugly, the algorithms are obviously working ones. Some are no doubt very clever. Carmark is one of many clever programmers. But he’s over-hyped.

[quote]Oh do you mean the stuff he built into those engines he sold that have been used by dozens of major game companies for most of the top real-time multiplayer titles created in the last 10 years which is still considered the standard and benchmark today and defined the algorithm for everyone else? Oh THAT bad networking code… 8)
[/quote]
What makes you think it is any good? Financial success does not equate to great code. Microsoft is a perfect example of that :).
It just has to work “well enough” to be licensed. There are a lot more people that don’t have the time to code it themselves.

[quote]Creating fast code is slowly becoming less relevant in todays world and it’s not because computers will become faster.

JIT compilers will continue to improve beyond the efficiency of todays JIT compilers.
[/quote]
Do something nasty to him. It’s a great opinion that will not work. Top CPU speed will not rise as much, and fast/slow code difference would be just higher.

to rest of this disscusion:
Comments when writting the code? They are unimportant for code maintenance. I offten return to a finished code after half year when I don’t remmember well all of its features. Then I’m writting a comments and do last version of a cleaning.

If you don’t remmember details of your code, you are in same situation as a future code maintenainer.

[quote]If you don’t remmember details of your code, you are in same situation as a future code maintenainer.
[/quote]
And it is that horrible experience that has cemented, for me, the importance of writing comments in my code.
Really, sometimes I come back after the weekend and don’t know what a piece of code does. (Strokes greying beard)
Having comments saves me stacks of time trying to decipher code.