Whil Hentzen wrote:
> So I'm working on this gig with a customer. The customer's rep is one of 
> these POOP folks, very anal about stuff that I'm somewhat more pragmatic 
> about.
> 
> One of their pet peeves regards method length. Somewhere they read in a 
> book that methods shouldn't be longer than 20 characters. I've got this 
> method that processes a table and dynamically creates objects based on 
> rows in the table. There are lots of different objects and bunches of 
> different rules, but they're all really simple. So my singular method 
> looks like:
> 
>    if <row condition>
>      set object property
>    endif
> 
>    if <two other row conditions>
>      set a different object property
>    endif
> 
>    do case
>    case <lots of cases>
>      set various properties
>    endcase
> 
> About 150 lines, maybe. Pretty straightforward. My associate wants me to 
> break this down into tiny methods, so the main method looks like so:
> 
> =ProcessConditoinOne()
> =ProcessConditionTwo()
> =ProcessConditionThree()
> etc.
> 
> and then write a couple dozen little methods that each consist of 3 to 7 
> lines.
> 
> Put the weapons away. Discuss.

In general, I tend to agree with your associate, but not in the simplest 
cases. IOW, if this is the only code that is going to call these 
methods, then leave it as it is. But if you end up duplicating code 
blocks, then refactor in to common methods.

Unfortunately, VFP doesn't allow nested functions, so it isn't easy to 
do this cleanly anyway (why put a ProcessConditionOne() method at the 
class level if it is only going to ever be used by MyMethod() - it 
pollutes the API).

So I'd say leave it the way you have it.

Paul


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to