Search this blog

Loading...

Monday, July 28, 2008

Commando

We are near a milestone of our project, I don't have any serious issue to fix, everything is going fine...

But one day I still had to enter the "commando" mode (see resign patterns if you don't know about them yet, they are important). There was a bunch of code, done by someone else, and never tested as we were lacking art assets to do that. Assets were finally delivered, game programmers try to enable that rendering feature, it fails, the problem fall back on me.

Now as, specifically, the game programmer that assigned the bug to me is a friend of mine too, I wanted to solve that as fast as possible, so he could stop slacking and return to coding asap. Problem was that I did not know the code, well, the entire subsystem really, it's a new technology that we're just integrating. I will design and probably implement the "correct" version of that functionality, but for now we wanted just to hack something to see, to evaluate GPU performance and let artists have something to work on.

Luckily I had the priviledge of working, in my previous company, with a guy, Paolo Milani, that could handle those kinds of situations perfectly. He is a powerful weapon (in the wrong hands), he can do almost anything (being good all round, at coding, hacking, designing, maths etc), but he was mostly used, due to lack of money, time, and too much ignorance, to do in a couple of hours the work of weeks. That of course resulted in code that no other human could ever understand, but still, sometimes those skills are helpful.

How you could notice him entering the commando mode? Simple:
  • The mouse wheel accellerated up to 10.000rpm.
  • The GPU fans started spinning because of the heat generated by Visual Studio text rendering.
  • With the other hand, while scrolling furiosly, code was being added "on the fly" all over the solution.
  • You could see the number of compile errors decrese in realtime, until reaching zero that marks the end of an iteration.
  • Looking at the Xbox 360 monitor, you could see over minutes the game taking shape... First flat shaded bounding boxes, then the bikes, the track, diffuse textures, animations, sound...

I'm not that good. I've never seen anyone else that good. Still, this morning, half asleep in bed, I was thinking about our (overly complex) math library, simd intrinsics, the wrapper we have for portability, the vector classes... then I turned on the other side, hugged the head of my girlfriend, and for a split second I surprised myself thinking if that head did inherit from our base vector class, were the data was, if it was properly aligned...

8 comments:

Victorus said...

arf funny post !

Remigiusz said...

After arriving here it took me less than a month to realize that Paolo is some kind of a Wunderwaffe;)
But don't be so modest, you also seem to be a fan of obscurity in code;) Or is only me who thinks that passing code around in delegates (where a simple loop will do) is confusing? :)

DEADC0DE said...

remigiusz: well your idea of my code is biased, as that project is not the best example of my skills.

I started it knowing nothing of C# (and you should be happy that I've introduced that language into the company!) so some stuff is... suboptimal, while the later code is better.

For example, the stuff you're talking about, was for me mostly an experiment, to see if you could do functional programming in C#. I did not even realize that there was already a "map" function in the standard containers...

But anyway, yes, in general it is much nicer to use functional primitives instead of loops :P

Remigiusz said...

I am not judging your coding skills, I am not even a full time programmer and if I were I would never be even half as good as you or Milani. I mentioned that piece of code more as a joke than a problem – Seeing it for the first time I got the impression that you were just showing off: “Look everyone, I’m clever and I have no problems writing in such (overly) complex way. Let David suffer debugging it.” ;)
To make it clear, although I disagree with some of your ideas (from those that I can understand), I believe you are a very competent programmer.

DEADC0DE said...

No offense taken, I was in fact just saying that you're right when you say that those things in my code are bad, there is a lot of bad code and even bad design in that project.

Unfortunately you have the burden of fixing all that... and even if you can remove the broken code that I did, I don't think you'll ever have time to fix the design, that unfortunately was not well done from the beginning, I did not have the idea of the domain, and the discussions with David underestimated a lot of problems than later appeared evident.

I consider that stuff as a prototype where we experimented with a lot of ideas, I learned a new programming language, for a thing done in two weeks was really good, then we should have deleted most of it and done it for real, instead of using that as our final solution, just patching more and more stuff into it...

Yours Truly said...

lol, good post indeed.

Unfortunately my experience is that code that has been half comandoed (i.e. comando pattern with a hint of strive to preserve encapsulation and sound engineering principles) almost never gets reworked. By the time we are able to fix it the next firefighting incident has occured and another commando is initiated... and so on.

What is worse is that comando code usually results in some subtle side effect in a different subsystem you wouldn't spot unless you have some serious testing process in place - especially for rendering.

Even worse, you make a comando version of a feature, artists get used it, you get time to do it properly but now you have to support the "baggage" because there are assets depending on it and half of the time you can't touch it.

And you need to learn to switch off... which incidently I need to learn to do as well :)

Diego Colombo said...

NO ONE TALKS ABOUT MILANI.
Paolo is so powerful that just a picture of him can resurrect a Xenon with the ring of death to life and run the code with fixes no one coded ever. If you think i am joking ask the author of the post the quickest a best way to fix bug without code

DEADC0DE said...

yours truly: the problem is deeper than just applying the commando... the thing I hate is writing code that I don't really understand, you know, when you copy&paste&modify... Your code seems to be ok, but maybe you're copying an ad-hoc hack that has been done (and not documented), replicating it in another place where it does not belong, or in general, you're writing suboptimal code... Code reviews are a great way of avoiding those risks, if there's at least someone that knows what that subsystem does...

diego: unfortunately, Milani is not with me anymore. I know that I shouldn't talk of Him, but now He is so far away... I've even lost his sacred image, as I lost my wallet :| The good thing is that here his allmighty powers are not needed, as people usually fix stuff in the proper way, and there's always at least someone that knows what to do... It's true that it requires 10 engineers instead of 1, but eventually it turns out not to be that bad, because the code is more readable by mere humans, and it does not take one week to do a menu page...