Quote:
|
Originally Posted by Cuog
Use alot of small Functions written by members that do very specific tasks. Don't be affraid to have call trees that are very long. It will save time and recoding later.
|
Be careful with this. Having very deep call trees can cause you to overflow the stack, which is not very large in an embedded environment like the IFI controller (and this is a real pain to debug). Also, remember that there is overhead with each function call, so if you go overboard with small functions not only do you risk stack problems but you're also likely using up more RAM and CPU cycles than necessary.
Most experienced software people will tell you that there is a 'sweet spot' for complexity of functions. If you don't simplify enough, you have huge functions full of spaghetti code. If you simplify too much, the code can also be difficult to read because there's no easy way to see what's going on overall. I'd suggest that functions which contain the primary logic of your program should be somewhere in the vicinity of 25-75 lines or so, with various 'worker' functions which are frequently used which might only be 5 or 10 lines. And as always, remember that comments are free

Use them often so when you return to the code next season you have some idea of what you were thinking at the time.