Ideal way to separate GUI and logic?

Steven D'Aprano steve at pearwood.info
Sun Jul 14 21:44:19 EDT 2013


On Sun, 14 Jul 2013 17:25:32 -0700, fronagzen wrote:

> My next question is, to what degree should I 'slice' my logic into
> functions? How small or how large should one function be, as a rule of
> thumb?

I aim to keep my functions preferably below a dozen lines (excluding the 
doc string), and definitely below a page.

But more important than size is functionality. Every function should do 
*one thing*. If that thing can be divided into two or more "sub-things" 
then they should be factored out into separate functions, which I then 
call. Possibly private, internal only functions.



-- 
Steven



More information about the Python-list mailing list