Week 13: Notes

This week we discussed topics related to software engineering, including

Here are a few notes on these topics. For more details, watch the lecture and tutorial videos.

program sizes

Typically we measure a program's size in the number of lines that it contains. The cloc utility is useful for counting lines in any program.

In the lecture we looked at the sizes of various real-world programs. Here are some examples:

As a rough estimate, a good programmer might write 1,000 lines of code in a month. So a program with 1,000,000 lines of code might take something like 1,000 person-months = 83 person-years of time to write. Probably no single person can understand every line in a program that large.

organizing and structuring code

Here are some basic tips:

debugging

Tips for debugging:

optimization and profiling

build systems

Almost any program that's larger than a few hundred lines will need some sort of build system. Here are some that we discussed in class:

testing

Any serious program needs to be tested continuously during its development.

The most basic way to test your program is manually, i.e. by running it and manually entering input or using it interactively. This generally doesn't scale well to larger programs. It's also difficult to test a program thoroughly in this way.

In recent decades there has been a major trend toward automated testing. One common form of automated testing is unit tests, which test individual pieces of functionality such as individual methods or classes inside a program. By contrast, system tests test the functionality of the entire program, e.g. by sending input to the program and checking its output.

There are many test frameworks which can help you write automated tests for your program. NUnit is one popular such framework for C#.

If a program has a graphical interface, it may not be so easy to test it in an automated way. However, if you write your program using a model-view architecture then you should be able to write automated unit tests for the model portion of your program at least.

To be very sure that software (or hardware) has no bugs, it is possible to write a mathematical proof of correctness of a piece of software (or hardware), and to check the proof in an automated way using a computer program. However this is relatively expensive and difficult, so it's not done so often in practice. Making this easier is an active area of research.