RE: Help With Better Design

2007-06-25 Thread Sells, Fred
> IMHO ... untested > > class LightBulb: > def __init__(self, on=False): self.IsOn = on > > def turnOn(self): self.switchIt(True) > def turnOff(self):self.switchIt(False) > > def switchIt(self, turnon): > if self.isOn==turnon: print "The Switch is Already %s

Re: Help With Better Design

2007-06-21 Thread apollonius2
On Jun 21, 12:22 am, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > (snip) > > >>> I would like to be able to get a good hold of the concept > >> state machines ? > > > Well both state machines and classes (objects). That may be a bit of a > > tall order to take on all at once but the

Re: Help With Better Design

2007-06-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) >>> I would like to be able to get a good hold of the concept >> state machines ? > > Well both state machines and classes (objects). That may be a bit of a > tall order to take on all at once but the concepts seem to be quite > related. They are, since OO was

Re: Help With Better Design

2007-06-20 Thread apollonius2
> I've written code that looks a lot like that, and it's > a perfectly acceptable pattern IMHO. I don't bother > with the variables ON and OFF, though, as they add no > clarity to simply using 'ON' and 'OFF' for the states. > > [...] > The test portion of the code is actually longer than > the cl

Re: Help With Better Design

2007-06-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Greetings, > > I have been working on a little project today to help me better > understand classes in Python (I really like Python). I am a self > taught programmer and consider myself to fall in the "beginner" > category for sure. It was initially sparked by reading

Re: Help With Better Design

2007-06-20 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: > > ON = "ON" > OFF = "OFF" > > class LightBulb: > def __init__(self, initial_state): > self.state = initial_state > > def TurnOn(self): > if self.state == OFF: > self.state = ON > else: > print "The Bulb Is A

Re: Help With Better Design

2007-06-19 Thread apollonius2
Thank you both for the insightful responses(I knew I came to the right place)! Steven -- The original inspiration was a "State Machine" your code re- write was what I was trying to accomplish but quickly got in way over my head. Thank you for expanding on that aspect of it. That will give me some

Re: Help With Better Design

2007-06-19 Thread Gabriel Genellina
En Tue, 19 Jun 2007 22:34:27 -0300, <[EMAIL PROTECTED]> escribió: > I have been working on a little project today to help me better > understand classes in Python (I really like Python). I am a self > taught programmer and consider myself to fall in the "beginner" > category for sure. It was initi

Re: Help With Better Design

2007-06-19 Thread attn . steven . kuo
On Jun 19, 6:34 pm, [EMAIL PROTECTED] wrote: > Greetings, > > I have been working on a little project today to help me better > understand classes in Python (I really like Python). I am a self > taught programmer and consider myself to fall in the "beginner" > category for sure. It was initially sp