"Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote in message news:1338326229.2616.31.camel@localhost.localdomain... > On Tue, 2012-05-29 at 17:06 -0400, Paul M Foster wrote: > >> On Tue, May 29, 2012 at 08:52:46AM +0100, Tony Marston wrote: >> >> > On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: >> > > A rule of thumb is no more than 50 lines per >> > > function, most much less. Back in the day when we didn't have nifty >> > > gui screens and an 24 line terminals (yay green on black!), if a >> > > function exceeded one printed page, it was deemed too long and marked >> > > for refactoring. >> > >> > I think the idea of setting an arbitrary limit on the number of lines >> > that a >> > function should contain is quite ludicrous and something which I will >> > completely ignore. If a function requires a hundred or more lines then >> > so be >> > it. The only reason to take a block of code and put it into its own >> > function >> > is when that code is likely to be called more than once so that it >> > conforms >> > to the DRY principle. If it is only ever used in one place then there >> > is no >> > point. >> > >> > The problems I have with creating lots of small used-only-once >> > functions is >> > as follows: >> > - you have to create a meaningful name for each function. >> > - all those functions should be arranged in alphabetical order within >> > their >> > containing file - having them in a random sequence makes it difficult >> > to >> > find the one you want. >> <snip> > > And yeah, alphabetical order? Really? This is a throwback to my 3GL days when all components within a file were arranged in alphabetical sequence so that they were easier to find when you looked at the printed listing. > Group them by similarity, sure. > But today, with IDEs that will jump straight to functions and class > methods, and the good ol' find tool on every editor I've ever seen, is > sorting them alphabetically really necessary? Seems like a waste of time > that is likely not going to be done by fellow developers working on the > same codebase. I have never come across an IDE that jumps to a function when you click on its name, so how does it return to where you jumped from? Rather than artificially reduce the size of a function to satisfy someone else's limited attention span I would rather use the scroll wheel on my mouse. Scrolling up or down within a single function is easier than searching/finding/jumping to a series of sub-functions which may exist at random locations within the same file. I will only split a large function into sub-functions when it makes sense to do so, and not because some nerd cannot scan more than 20 lines at a time. -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php