Captin... The cyclometric complexity meter is at max... I canne give it any more.

Reflection can seriously help with big else-ifs. If your switching on a variable use the variable name and value as part of the class name and then do;

Class blahHandlerClass = Class.forName( "BlahHandlerFor"+value );
BlahHandler blahHandler = blahHandlerClass.newInstance();
blahHandler.doYourWork();

It splits your code into more manageable chunks, allows you to add handlers for new values without touching the motherload, and it makes it look like you're a java ninja blending in with the workplace :).

Al.

Dave Newton wrote:
Seriously, refactor your code. 5K lines of code in 7 files
could hide all manner of nasties.

We have a 1M class where I'm at now. That's *1M* of source. 30k+ lines, mostly 
if-elseif.

It broke our cyclometric complexity meter, had to put in a bigger fuse. It 
makes Eclipse cry. It makes *me* cry. Kinda like this thread.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
--
Al Sutton

W: www.alsutton.com
T: twitter.com/alsutton


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to