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.
Command design pattern
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
精彩评论