What design plattern is needed to solve my problem?

H

howa

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.
 
B

bencoe

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.

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.
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top