# Speedy Method Delegation

**URL:** <https://forum.kirupa.com/t/speedy-method-delegation/310293>\
**Category:** flash\
**Created:** [June 7, 2010, 3:11am UTC](https://forum.kirupa.com/t/speedy-method-delegation/310293 "2010-06-07T03:11:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FractalPhi](https://avatars.discourse-cdn.com/v4/letter/f/b2d939/32.png) [@FractalPhi](https://forum.kirupa.com/u/FractalPhi)\
**Post date:** [June 7, 2010, 3:11am UTC](https://forum.kirupa.com/t/speedy-method-delegation/310293/1 "2010-06-07T03:11:29Z")

</div>

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?
