Hello, I want to ask...
What design plattern is needed to solve my problems below?
P1.
Input -> ProcessA -> ProcessB -> ProcessC -> Output
Suppose Process A, B, C might use different alogorithm to solve,
e.g. ProcessA (A1, A2, A3), ProcessB (B1, B2), ...
so my program should be flexible enought to change the alogroithm on
runtime.
P2.
Similar to P1, but when some algorithms are selected, the flow
changed, e.g.
If I use A1, I can only use B2, but not B1
So considering both as 2 questions, what kind of plattern you would
suggest?
thanks.
bencoe@gmail.com - 03 Jul 2007 19:36 GMT
> Hello, I want to ask...
>
[quoted text clipped - 22 lines]
>
> thanks.
Just use an Abstract Class (or an interface for that matter) for your
algorithms, I don't think you need any thing too fancy for what you're
describing --
If you really do feel like being fancy, try the strategy pattern.
http://en.wikipedia.org/wiki/Strategy_pattern
Ben.
howa - 04 Jul 2007 03:45 GMT
On 7 4 , 2 36 , ben...@gmail.com wrote:
> > Hello, I want to ask...
>
[quoted text clipped - 34 lines]
>
> - -
Thanks. I think this is what I looking for.
Roedy Green - 03 Jul 2007 21:35 GMT
>So considering both as 2 questions, what kind of plattern you would
>suggest?
It has been quite a while since I read the book. The one that my gut
says is a likely candidate is Command.
You might also check out Chain Of Responsibility. I forget what it
does.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com