Advice on a style issue(writing funcions)

I once read an author that suggestion that one shouldnt write a function (or module) that took more then a screen(would be nice to know what resolution and letter size he meant :)) .. Now I usually write functions that take more than a screen, perhaps two or two and half and in myh opinion there is no convenient way of splitting it up or giving parts of it to another subfunction or subroutine.. Any advices for this style issue ?

On 13 Apr 2003 at 9:10, Raúl Gutiérrez Segalés wrote: Date sent: Sun, 13 Apr 2003 09:10:22 -0400 (PYT) From: Raúl Gutiérrez Segalés <rau@campoalto.edu.py> To: <suse-programming-e@suse.com> Subject: [suse-programming-e] Advice on a style issue(writing funcions)
I once read an author that suggestion that one shouldnt write a function (or module) that took more then a screen(would be nice to know what resolution and letter size he meant :)) ..
Now I usually write functions that take more than a screen, perhaps two or two and half and in myh opinion there is no convenient way of splitting it up or giving parts of it to another subfunction or subroutine..
Any advices for this style issue ?
This is advice that's often offered, and like all advice it shouldn't be followed slavishly - it really depends on the circumstances. At it's worst it results in horriblely dense and unreadable code as the programmer tries to make what he wants fit into one screen. At its best it encourages programmers to think about what they are putting in to their functions. I would have said that a better piece of advice would be to suggest that functions should only do one thing, unless they are higher level functions, in which case they should call a series of functions, each of which does one thing. If you follow this, then your functions will generally only take up a relatively small number of lines without having to artificially squash them down. alan -- http://www.ibgames.net/alan Registered Linux user #6822 http://counter.li.org Winding Down - Weekly Tech Newsletter - subscribe at http://www.ibgames.net/alan/winding/mailing.html
participants (2)
-
alan@ibgames.com
-
Raúl Gutiérrez Segalés