i came across implementation/design problem.
Lets assume we have an input class:
class A {
public Foo1 foo1(Bar1 bar1) {...}
public Foo2 foo2(Bar2 bar2) {...}
...
public FooN fooN(BarN barN) {...}
}
than, we have some classes, that contains some of A's methods.
class X {
public Foo1 foo1(Bar1 bar1) {...}
public Foo4 foo4(Bar4 bar4) {...}
}
class Y {
public Foo2 foo2(Bar2 bar2) {...}
public Foo3 foo3(Bar3 bar3) {...}
}
class Z {
public Foo1 foo1(Bar1 bar1) {...}
public Foo4 foo4(Bar4 bar4) {...}
public Foo9 foo9(Bar9 bar9) {...}
}
i hope You get general idea - it's basically a routing design.
Now, depending on some inner barX value on my A method call, i have to choose 'right' class (from X.. Z) to call same method with same parameter and return it's value. How should I do it properly without building "IF WALLS" in every function call?
My problem: I cannot modify classes X, Y, Z directly as these are generated sources.
I know i can tackle this problem with some additional method, that will take method name as parameter together with original parameter, that do Single "IF WALL" and call proper class method with reflection. But I don't like this solution, hope I can find some help here.
Ps. this is not an academic problem.
Aucun commentaire:
Enregistrer un commentaire