Size of a Function

There is a rule of thumb for the length of a C-function:

 

Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well.

 
-- L. Torvalds  

It is also true for Scilab functions with the exception that high level functions or functions that could eventually be called from the command line directly should be harnessed. See also: the section called Bulletproof Functions in Chapter 4. Therefore, they are usually much longer than just two screenful. But the structure decomposes quite naturally in two parts: the argument checking and the computation part. What remains true is that a Scilab function too should do only one thing and do that well.

For more information about programming style consult "The practice of programming" [kernighan:1999] which is centered around C-like languages but offers extremely valuable advide throughout. The Camel, [wall:1996] has a section that is called "Efficiency" in chapter 8. It is as insightful as it is fun to read for the authors discuss the various optimization directions. They do not hesitate to put up contradicory suggestions in the different optimizations paths.

Conclusion of this section: Whatever makes the code's workings more obvious to the reader is good. In other words: "If it makes ya high, or saves you taxes, then – by any means – do it!"