Hi,
I have a class that acts as the concrete strategy for several types of context classes. In this class, I have a method implementation that delegates to one of several private methods depending on the class’s state property. I’m trying to figure out the most speed-efficient way to call the appropriate delegate methods without violating OOP design.
Right now, I’m using what I understand to be a hash look-up, such as…
[FONT=Courier New]var state:String = “foo1”;
public function facadeMethod(param1, param2):void {
this[state](param1, param2);
}
private function foo1(param1, param2):void {}
private function foo2(param1, param2):void {}[/FONT]
I’m pretty sure this isn’t the best way, but the only other solution I know of is a switch statement. Because the context object will be looking for the facade method (not foo1 or foo2), I can’t simply make each method public.
Does anyone have any suggestions?