OO approach to decision sequence?

Chinook chinook.nr at tds.net
Sat Jun 18 14:53:48 EDT 2005


On Sat, 18 Jun 2005 09:10:25 -0400, George Sakkis wrote
(in article <1119100225.438987.221850 at f14g2000cwb.googlegroups.com>):

> "Chinook" wrote:
> 
>> I understand what you are saying.  The point I'm messing up my head with
>> though, is when the entity (tree node in my case or variable record content
>> deconstructing in the aspect example I noted) is not an instance of a class
>> already - it is obtained from an external source and only decipherable by 
>> its
>> content.
>> 
>> In practical terms that leaves me with some decision sequence regardless and
>> I was wondering (from what Chris Smith said) how that might be done in OOP.
>> The whole problem may be that I'm reading too much into what Chris said :~)
>> I will dig back through the Tutor archives as you suggested.
> 
> What you are looking for is what is called the 'factory method pattern'
> (http://en.wikipedia.org/wiki/Factory_method_pattern) and it's one of
> the cases where OOP doesn't eliminate the if/elif/elif (or switch in
> C++/Java). That's ok though because, as you noticed, at some point you
> have to take a decision. What's important is the "once and only once"
> principle, that is all the decision logic is encapsulated in a single
> method (or in python in a single function) instead of being replicated
> every time you want to use an existing Node.
> 
> Regards,
> George
> 
> 

George,

Yes, that answers my question of how the issue is approached in OOP - thank 
you.  I'll do some more googling to find examples in Python and then try 
refactoring my little utility.  The effect on my little utility will be a 
verbose abstraction of a specific efficient top-down approach, but the 
intended goal is to learn how to better facilitate extensibility.  

Thanks to all that took the time to wade through my post and especially to  
those that offered their thoughts, 

Lee C





More information about the Python-list mailing list