[Tutor] Improving My Simple Game Code for Speed, Memory and Learning
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):
>> 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:
> 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.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor