flipCode - Tech File - Jeroen Bouwens [an error occurred while processing this directive]
Jeroen Bouwens
Click the name for some bio info

E-Mail: flipcode@jeroen.ws



   04/01/2002, Thoughts On Software Development


This thread in the general development forum inspired me to write this tech-file entry. It seems that every new, young software developer at some point decides the “experienced” people are all wrong, and he/she doesn’t need to do things “the right way”. What’s wrong with goto? Why are public variables bad? Who needs Object Orientated Programming anyway? I don’t need comments, I KNOW what my code does!

I think I understand where this comes from. Most programmers start young, they work alone, and their projects are small. This means they do not see any direct benefit from the “proper” methods. As one person in the thread I mentioned explained, “I haven’t used a private variable since 1997. The funny thing is I’ve encountered zero problems that can be attributed to this”, and I completely believe him.

But….

Although I don’t consider myself an incredibly good software developer, I have gained some experience in the last three or four years. If there is anything I learned, it is that all the “proper” ways of doing things can definitely have enormous advantages in the real world.

All this Object Orientation, Encapsulation, Polymorphism and Proper Design stuff was not invented because it is cool or sexy, nor does it stem from some purist desire to have “nice” code. It came from the experiences of earlier software developers who ran into all kinds of problems when they attempted ever more complex and larger-scale software projects. It is intended to make real-world software engineering easier, more reliable and more predictable.

In a serious project, a lot of people work on a large code-base (10,000’s to 1,000,000’s of lines of code). Every module interacts with other modules, and some basic modules are used by a LOT of other modules. This means that changing interfaces can have severe side effects that take a lot of resources to fix. Encapsulation prevents a lot of interface changes.

People get hired, write some code, and leave again. You will find yourself modifying and debugging code you didn’t originally wrote yourself. A uniform code-style and

Even worse, over the course of a project requirements are bound to change. Don’t complain that your code must be rewritten almost from scratch to accommodate this requirement change, that’s your problem. A good design recognizes this and makes the most likely changes easier.

Moreover, when a project is finished you will have to maintain your product. Bug fixes, patches and updates will be necessary. Maybe small features need to be added. You would like to minimize the time you spend on such things, if possible. “Proper” design and implementation leads to code that is easier to test, debug and maintain.

The key characteristics of a successful project are that it is: On time, within budget and according to spec. Over time, experience with such projects led to tons of “best practices”: Ways of doing things that increase the chances a project will achieve these three goals. Things like using a revision control system (CVS), a bugtracker (mantis), a unit-test framework (cppunit), a code documentation system (Doxygen) and reviewing each others’ code fall in the “best practices” category.

Like it or not, games are made, or at least published, by companies. That means money is involved, and it means “on time” and “within budget” are important. This in turn means that these best practices are very useful, if not essential, to the success of your current and future projects.

“But”, I hear some of you say, “All this doesn’t apply to me. I am programming GAMES, not databases or aircraft control software”. Let me help you get rid of this idea right away: Game programming is not, in any fundamental way, different from any other branch of software development.

Granted, Game Programming is different in several ways from more conventional programming. For instance:
  • Games are typically among the most demanding applications in terms of performance on a certain platform.
  • Game projects don’t have THAT much maintenance. Maybe some bug-fixes, but because “correct” functionality is often less well defined for a game, you can get away with a lot that would be fatal in a business app.
  • Games usually do not really evolve. You won’t see Black&White version 2.4 anytime soon for instance. So the life-cycle of a game is much shorter than that of, say, an office suite. This means reuse of code is limited compared to evolving products, where version 2.4 is largely the basis for version 3.0.
  • Game requirements are more flexible. A missing feature, even a fairly big one, won’t necessarily deter gamers from buying your game.
  • But in the end, making a game is still software engineering, just like making any other piece of software. Therefore game developers benefit just as much from good practices as anybody else.

    This doesn’t mean that OOP and all the other things I mentioned are some sort of magic bullet that make software engineering a breeze. It also doesn’t mean that all the “old” techniques cannot be used anymore. C is very appropriate in many situations (Gameboy Advance programming, for instance) and even assembly has its place in embedded applications and for some tight loops for instance.

    But it does mean that even though it is not immediately obvious what the benefits of some practice or technique are, that doesn’t mean it has NO benefit.

    It was a while ago that I read something like this on the flipCode message boards:
  • Non-programmers think programming is hard.
  • Average programmers think programming is easy.
  • Good programmers KNOW programming is hard.
  • I couldn’t agree more.

    Happy coding, Jeroen





  • 04/01/2002 - Thoughts On Software Development
  • 09/10/2000 - Observe Your Objects
  • 01/31/2000 - Factories
  • 09/14/1999 - Polymorphism and Inheritance
  • 08/14/1999 - Object Design
  • 06/04/1999 - OpenGL Mania
  • 05/04/1999 - 3D Clipping
  • 04/29/1999 - Introduction

  • This document may not be reproduced in any way without explicit permission from the author and flipCode. All Rights Reserved. Best viewed at a high resolution. The views expressed in this document are the views of the author and NOT neccesarily of anyone else associated with flipCode.

    Download The Sample Program: ManicMotion.exe

    [an error occurred while processing this directive]