2005-02-26

 

Code dependencies

They suck! Well, this probably isn't fresh news to anyone, but right now I'm working with code where basically everything includes everything else. The code is template-heavy so that makes things even worse. Try changing that file without 20 minute rebuild later - good luck!

Yeah, I know, the code is a product of 2 years of wandering in the darkness :) - prototyping, adding something and removing something, and when you constantly have to actually produce "working demos" in short timeframes, it ain't easy to actually sit down and refactor whole thing. Oh well, the reality...

Still, code with lots of dependencies does suck of course.

On the other hand, I'm pretty happy with the module I'm writing. All the outside just needs one header file that's right now 76 lines long and that includes only very basic "resource id" header file. The insides of my module also need some of the outside functionality; I've written some "outside interface" for that - a header file with something like 50 lines and also absolutely no includes.

That's what I consider to be a low-dependency interface. That's good. That doesn't suck :)

[EDIT] The code I was referring to isn't so bad (e.g. it really doesn't "includes everything else", but "includes quite large amount of stuff"). I'm just somewhat frustrated at the moment, and anything that's not very ideal in the codebase irritates me.

Comments
My favorite anecdote for code interdependencies: in an older codebase of ours, for an 2D RTS game, whenever you touched the fog-of-war code, the first file to recompile was network.cpp, the low-level TCP/IP socket code. Don't ask :-)
 
whee, hold on a second...
I was working on that project, before, and I'm pretty much sure, that you are talking about the code dependencies and NOT about interdependencies (not so many of the actual interdepencies there). What you experiencing are dependencies of the gamelogic code on the lower level modules. Let's face the truth here, gamelogic IS dependent on the rest of your codebase, even by it's definition and you definetly want that to happen. By the way, you're dealing with quite large number of different behaviour units (definetly more than 5 of them ;) ). So changing lower level module interface will definetly trigger recompilation of all gamelogic.

Now here goes the templates - yes, they are inheretently evil, since they are in .h files. And we're paying the price for using them :)

Although, I'm pretty much sure that somebody forgot to tell you about the special #define, separate static libraries for unit testing (only several types of units is usually enough for testing lower level, right?) and sometimes using nil policies or policy with less functionality(usually you don't even need an animation policy, right?) (and that's were templates really can shine). So at the end of the day, even working on interfaces which are heavily used by gamelogic you can strip it down to 2-5 files recompilation. Personally I was much more irritated by long link times (several compile time seconds, against 2-5 minutes of the link time, damned templates with long symbols :) )

And ofcourse there are number of dead includes, which should be removed as soon as possible.
 
bah, the real nest of interdependencies there - is notorious MyGame, and people who introduced it, should be hunt down :)
 
ReJ, take it easy :)

Yes there aren't that many weird (inter)dependencies in there (certainly not something like Ivan-Assen said... maybe because there's no networking code :)).

I was slightly wrong - my main complain would really be about the dependencies. Lots of dead includes, plus lots of "I have everything in here" header files, plus lots of code in templates (so the header files are really huge). The templates and the price(s) for them is a topic for another story :)

I know about the magic "test units only" stuff, yes. Long link times can be reduced by turning on incremental linking on release build (you lose some optimizations, but oh well).

In the end, come on, you know me, I'm always complaining about insignificant things.
 
No problem, I'm cool :)

Just wanted to point a difference between inter- and general dependencies: while 1st thing is bad in most circumstances, the 2nd isn't bad by default...

Speaking about the code - one always must find a time for code refactoring... otherwise it will suck in any case :(

And in the end, come on, you know me as well ;) - absolutely no offense was meant...
 
Post a Comment

<< Home