next up previous
Next: Model View Controller pattern Up: Introducing software design Previous: Introducing software design

Subsections

The importance of good software design

So now we have a minimisation and a simulation program. At current, it is very simple, and does not provide much functionality. What if we want to add some text output to display the amount of energy? What about colouring the atoms to display energy or adding arrows to display force? What if we wanted to change the platform of the program, and the platform we were using didn't support Visual Python?

These possibilities could of course all be implemented. But the question is how easily could they be implemented? And what will our code look like after one, two, three or even more functions had been added? The answer is that as more and more functions get added, the code will look messier and messier, and implementing new functions will get more difficult.

Imagine if we wanted to add the ability to print out the kinetic energy, potential energy and total energy of the system. First we would implement routines to calculate these values. The potential energy routine is already in place, however the kinetic energy will need to be added. Now, in one line of code, we print out the energy. Of course, since we have both a minimisation and a simulation program, whatever work was done would need to be mirrored in the other. This is where things get interesting, what if a bug was found? It would need to be fixed in both.

Let's now add another function. We want the ability to turn on or off the text and visual displays. The quickest way is to add if statements to our code, displaying the output only if some condition was true. This again has to be mirrored in both programs, and error fixing would be messy.

Now we want to combine the minimisation and simulate functions, we want to minimise a structure so that it's stable, and then fire an atom at it with the simulate function. This, would require almost a complete rewrite of our program.

The software crisis

As can be seen, with no formal methods of design from the start, our software can very quickly become very difficult to manage. Such software is typical of the software crisis. Though we won't go into detail, further detail can be found here.

It is therefore important to employ known methods of software design to almost any software we write.


next up previous
Next: Model View Controller pattern Up: Introducing software design Previous: Introducing software design
James Roper 2004-02-12