[Tutor] Improving My Simple Game Code for Speed, Memory and Learning

Alan Gauld alan.gauld at btinternet.com
Sat Jan 3 19:20:26 CET 2015


On 03/01/15 16:14, WolfRage wrote:

>>>      def check_total_and_eliminate(self, first, second, third):
<snip>

Steven said:
>> I think this method does too much. I would prefer to see it split into
>> two methods, one to check the total, and the other to eliminate the
>> cells if needed:
<snip>

> Yes, another example of me trying to have my functions do too much.
> Thanks I will break it up.

There is a strong hint in the function name. Any time you call a 
function xxxxANDyyyy() it probably should be two functions xxxx()
and yyyy() :-)

It's similar with classes, any time you write a class
called XXXManager you should check that you are not just
writing methods that should be in XXX itself.

Good name choices serve many purposes.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list