1、单件模式
Class:SingletonClass
Option
Explicit
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Count
As
Integer
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Class_Initialize()
If
gSingleton
Is
Nothing
Then
Set
gSingleton
=
Me
End
If
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Function
GetInstance()
As
SingletonClass
Set
GetInstance
=
gSingleton
End Function
模块声明
Public
gSingleton
As
SingletonClass
Public
Function
SetName(Name
As
String
)
SetName
=
Trim
(
UCase
(Name))
End Function
Implements IMethod
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Base
As
IMethod
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Class_Initialize()
Set
Base
=
New
IMethod
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Class_Terminate()
Set
Base
=
Nothing
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Function
IMethod_SetName(Name
As
String
)
As
Variant
IMethod_SetName
=
Base.SetName(Name)
IMethod_SetName
=
IMethod_SetName
&
"
0001
"
End Function
3:工厂模式:
CreateObject
4:ComUnit的一个设计模式
Implements ITestContainer
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Property
Get
ITestContainer_TestCaseNames()
As
Variant()
ITestContainer_TestCaseNames
=
Array
(
"
TestString
"
)
End Property
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Sub
ITestContainer_RunTestCase(oTestCase
As
ITestCase, oTestResult
As
TestResult)
CallByName Me, oTestCase.Name, VbMethod, oTestResult
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Sub
TestString(oTestResult
As
TestResult)
End Sub
使用TestCaseNames向外暴露自身扩展的成员。
使用类似于TestString的方法(接口参数一致),来扩展自身功能。
借助TestResult来贯穿类处理的总线。
使用TestRunner来处理符合ITestContainer接口的类。
5:观察者模式
Option
Explicit
'
Ineteface Subject
Public
Sub
Register(obs
As
Observer)
End Sub
Option
Explicit
![None.gif](/Images/OutliningIndicators/None.gif)
'
Interface Observer
Public
Sub
Notify(msg
As
String
)
End Sub
'
frmMain
Implements Subject
![None.gif](/Images/OutliningIndicators/None.gif)
Dim
cc
As
Collection
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Command1_Click()
Dim
c
As
Observer
For
Each
c In cc
c.Notify
InputBox
(
"
Caption:
"
)
Next
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Form_Load()
Set
cc
=
New
Collection
Dim
o
As
frm1
Set
o
=
New
frm1
o.Ini Me
o.Show
Dim
oo
As
frm2
Set
oo
=
New
frm2
oo.Ini Me
oo.Show
![None.gif](/Images/OutliningIndicators/None.gif)
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Subject_Register(obs
As
Observer)
cc.Add obs
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
'
frm1
Implements Observer
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Sub
Ini(s
As
Subject)
s.Register Me
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Observer_Notify(msg
As
String
)
Me.Caption
=
msg
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
'
frm2
Implements Observer
![None.gif](/Images/OutliningIndicators/None.gif)
Public
Sub
Ini(s
As
Subject)
s.Register Me
End Sub
![None.gif](/Images/OutliningIndicators/None.gif)
Private
Sub
Observer_Notify(msg
As
String
)
Me.Caption
=
msg
End Sub
Class:SingletonClass
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
模块声明
![None.gif](/Images/OutliningIndicators/None.gif)
2、方法继承
Class:IMethod
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
Class:NewMethod
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
3:工厂模式:
CreateObject
4:ComUnit的一个设计模式
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
使用TestCaseNames向外暴露自身扩展的成员。
使用类似于TestString的方法(接口参数一致),来扩展自身功能。
借助TestResult来贯穿类处理的总线。
使用TestRunner来处理符合ITestContainer接口的类。
5:观察者模式
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)