This is a disciplin, that makes programs easy to read and correct, and work better. It contains several items.
Comments in the program can describe what the program should do. You can choose to have a comment for 100 lines ("Below the database and its 7 tables are updated."), or for every line ("Make connection to the relevant database."), or something in between.
Space (tabulation, space and line breaks) can arrange the program in different ways, to make it easier to read - like we bend other kinds of text to make it more readable.
Platform independency - that the program works on all computers (including software), that you might imagine - also computers with old and unusual software.
Error checking - often the file system, databases etc. are used, and these don't always cooperate. In nice programming you know this, so the user can get a nice error message (i.e. one I have written), instead of something more or less understandable from the program.
No superflous code - if you have worked with a program for a long time, there are often bits and pieces all over the place no longer in use, only there to confuse. It's okay to have a phase to remove extra code. If you use a development environment, there might also be extra code, that has to be removed by hand.
Good names - both variables and functions can be named by the programmer, and should have good names. A counter might be named i, e.g. if it's only alive for 4 lines, in a for loop. Another variable might be called noErrors, and live for many lines. It's easier to remember what the variable contains, when you bump into it. And it should contain the number of errors, and not the width of the browser!
Normalization, referential integrity etc. - or in other words, the tools that support and optimize the use of databases.
Nothing hard coded - sometimes you write something directly in a program, when the correct procedure would be to get it from a table in a database or something similar. It's actually redundancy to have it in two places. This is called hard coding. And it's not nice.
Concept last updated: 06/05 2004.
- Eksempler på programmerings-sprog - Kommentarer, Funktion