"Che M" <pine...@hotmail.com> wrote

I have some functions that seem kind of long to me.  One of them, with

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?

The length as such is not the critical factor, its the maintainability and readability. Can you function be easily understood by another programmer? Can you make changes to the function without changing the interface (which implies changes elsewhere in your code)

Where you have a lot of if statements you might benefit from using a dictionary of functions or a function which returns a function. But there may be good reasons to keep the if statements too.

Sorry, but a generalised question can only get a generalised answer.
57 lines of active code is big but not ridiculous. Over 100 liones I would be looking closely at breaking it up just for readability.

Remember the old adage that a function should ideally fit on a single editor screen (or sheet of printout) - when I started that meant 25-60 lines was the range, now you can go up to 60-100 lines if needs be...

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to