TSB said:
Quote:
Hi everyone,
>
I think algorithm is very important for every computer language. But I
don't know another important things.
>
I am newbie to computer languages, so anyone can tell me what the most
important things are to write a program?
0) In C at least, array indices start with 0, because an index is not a
count but an offset. Failure to understand this is the cause of many bugs
in newbie programs.
1) Know what you're trying to achieve. Write it down. Programming then
becomes the iterative process of getting your program's actual behaviour
to match the behaviour that you've written down.
2) Anything that can go wrong *will* go wrong. Make sure it can't, or at
least that you handle it when it does.
3) All code should do something good or stop something bad happening. If
the code is neither a positive benefit or at least a safeguard, rip it
out.
4) Everything Has To Be Somewhere. Manage your storage properly.
5) Know your language. Don't assume that local assumptions work everywhere.
If your program will have to work on more than one machine (and this
eventually happens to most useful programs), make sure you understand the
difference between "the C that works on THIS computer" and "the C that
works on ALL computers".
6) Never put more than seven items on any list.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999