WIZARDELF
WIZARDELF

Reputation: 3885

which design pattern should i use for executing distinct methods with respect to different objects?

a class A has 3 boolean fields, and there is a set of objects of this class. i need to execute different processing for each object, in terms of the combination of its 3 fields. what pattern should I adopt?

public class A {
    boolean a, b, c;
}

thank you.


daniel

Upvotes: 1

Views: 58

Answers (1)

Miserable Variable
Miserable Variable

Reputation: 28752

Look up registry pattern. Essentially you define an interface AHandler and implement it for each combination you want to process.

Then, create a Map<A, AHandler> and statically initialize it with the handlers. Look up this map to find the handler to process each combination.

Upvotes: 1

Related Questions