我只是碰到了某种形式的代码,并得到了相当多的震撼:直接调用方法,或者Raise事件调用方法(事件处理程序)?
代码片段:
Class ABC
Private Event Event123()
Private Function ParentMethod()
RaiseEvent Event123()
End function
Private Function ChildMethod() Handles Event123
... code here
End function
End class
(注意功能和事件是私人的,该代码是用来内的。唯一的类) (另请注意,该代码是在VB,但这种模式可以应用到其他语言)
通常情况下,我只想直接从ParentMethod致电ChildMethod,象下面这样:。
代码片断2:
Private Function ParentMethod()
ChildMethod()
End function
我想知道,是代码片段一些类型的最佳/推荐的做法?为什么?
是的,我同意你的意见。这就是为什么当我看到代码时我“感到非常震惊”。 :) – Gan 2010-10-07 02:26:38