Re: Function size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 23, 2012 at 5:49 PM, shiplu <shiplu.net@xxxxxxxxx> wrote:
> On Wed, May 23, 2012 at 8:14 PM, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:
>
>> Hi gang:
>>
>> 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.
>>
>> You hit upon a theory of mine -- and that is our functions grow in size up
>> to our ability to view them in their totality. When our functions get
>> beyond that limit, we tend to refactor and reduce.
>>
>
> When number of lines becomes the criteria of function size? Wouldn't it
> depends on the task the function is doing? I follow this rule, *Each time I
> end up need a code block I wrote earlier, I convert it to a function. *So
> simple.  This way you re-factor your code automatically and you dont do any
> copy paste.  Last year someone on Stackoverflow asked something like
> this[1]. And that was my answer.
>
>

Hi,

While this could be one reason to start a new function, it should not
(IMO) be the only reason. Sometimes you can have a large complicated
function, with say 200 LOC. While I wouldn't need any of these lines a
second time, I usually try to rip blocks of say 50 lines out and put
it in a seperate function, so that the main function itself is easier
to understand.

- Matijn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux