Design pattern question
Uwe Schmitt
uwe.schmitt at procoders.net
Wed Aug 21 05:51:06 EDT 2002
Karl Schmid <schmid at ice.mpg.de> wrote:
> Now I would like to instantiate the abstract class, but to obtain an
> instance of either the Cap3Assembler or PhrapAssembler class depending on
> the assembler_type variable.
>>>> assembler = SequenceAssembler(assembler_type)
> Is this possible?
you cold use someething like a plugin, but then the interface and
implementation is not really seperated:
class GeneralAssembler:
def __init__(self, algorithmclass):
self.algorithmclass = algorithmclass
def run(self, data):
# do something with self.algorithmclass and data
# maybe self.algorithmclass.calculate(data) ...
class Algorithm1:
def calculate(data):
...
class Algorithm2:
def calculate(data):
...
now you can use
myassembler=GeneralAssembler(Algorithm1())
myassembler.run(data)
o.k. ?
Greetings, Uwe
--
Dr. rer. nat. Uwe Schmitt Computer science is no more about Computers,
uwe.schmitt at procoders.net than astronomy is about telescopes. (Dijkstra)
http://www.procoders.net
More information about the Python-list
mailing list