[Tutor] functions--how long is too long?

Che M pine508 at hotmail.com
Tue Dec 8 02:37:34 CET 2009


I have some functions that seem kind of long to me.  One of them, with
white space, comments, print statements, and some commented-out lines,
is 118 lines long.  If I remove all that, it is 57 lines long.  I get the sense
that is inappropriately long for a Python function.  

The length of it is due to a number of if statements--things it needs to
check in terms of the state of the app at the time it is called.  So there
are a number of conditional (and "subconditional") parts to it, and what
it does in response to those conditions.  In fact the word "if" appears in
it 12 times.  

I realize I can and should refactor parts that are used in other places
in the code, but I don't there are that many in some of these.  Is
there a better way to think about organizing this?

Thanks,
Che
 		 	   		  
_________________________________________________________________
Windows Live Hotmail gives you a free,exclusive  gift.
http://www.microsoft.com/windows/windowslive/hotmail_bl1/hotmail_bl1.aspx?ocid=PID23879::T:WLMTAGL:ON:WL:en-ww:WM_IMHM_7:092009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091207/d206dc74/attachment.htm>


More information about the Tutor mailing list