Re: Re: Function size

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

 



On Tue, May 29, 2012 at 11:06 PM, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx> wrote:
> OMG in alpha order?! At best, I might group them together by function
> type, with some comment notation in the file. But not alpha order. I
> prefer not to have "forward declares" in my files, so I generally
> arrange functions so that those called by other functions later are
> defined before they're called. (Probably a holdover from my C days; PHP
> doesn't care.)
>
> No offense. I never even thought about arranging functions in
> alphabetical order. But I don't think I'd do it.
>

Like most of us on this list (I think), I agree with you that
alphabetical order really doesn't make any sense.

>> - when browsing through the code you have to keep jumping to another
>> function, and then returning to where you came from.
>>
>> I don't know about you, but I would rather use the scroll wheel on my mouse
>> than keep jumping from one position in the file to another.
>>
>> Another problem I have encountered in the past with such an idea is that it
>> encourages a stupid programmer to decrease the number of lines of code by
>> compressing as many statements as possible into a single line, which then
>> makes the code less easy to read and understand. This is much worse than
>> having more than 20 lines in a function.
>
> I think a lot of coders try to be kewler than the next 18 guys who are
> gonna have to look at the code, so they use a lot of "compression"
> techniques to reduce LOC. Plus, they're lazy. I'd rather see everything
> with lots of spaces and plenty of comments and blank lines. Especially
> since I'm sometimes that 18th guy to look at the code.
>
> Paul

Paul,

Are you stating here that compression is a bad thing?

That means you consider this nice:

if ( action == A )
{
    doA();
}
else if (action == B )
{
    doB();
}
else
{
    doC();
}

Or perhaps flooded with comments that merely say the same as the code does?

I'd go for
if(action == A)
    doA();
else if(action == B)
    doB();
else
    doC();

or , if it's really that clean, i'd probably go for
if(action == A)  doA();
else if(action == B)  doB();
else doC();

- 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