views:

54

answers:

2

I have a menu click event that looks something like this....

Public Sub ToolbarManager_ToolClick(sender as Object, e as EventArgs)
    Case "New"
        CreateNewFile()
    Case "Save"
        SaveCurrentFile()
    Case "Exit"
        ExitApp()
    Case.......
    etc...
    etc...
End Sub

This strikes me as being 'ugly' - but I'm unsure of the 'best' way or the most appropriate way to clean it up.

+2  A: 

Command design pattern

uvita
+1  A: 

If the switch case is just in one place, I'd bite my lip and live with it.

If it's mushrooming everywhere, I'd try to use Replace conditional with polymorphism

Gishu