VB implementation abstraction

zhaozj2021-02-16  54

VB implementation abstraction

Playing VB has been around 1 week. I feel that VB can also develop applications in the OO method. Because VB supports COM

And provide a class module to achieve a package. It also provides an interface support. The interface can be implemented via IMPLEMENTS.

Therefore, inherit is achieved. If you can achieve the effect of inheritance, of course, you should count the Adapter mode.

Of course, most object-oriented design patterns can be implemented via VB. It can also be modeled by UML. Because

VB supports the reference delivery message. Most OO features can also be simulated. Here I introduce an abstract class implementation

In fact, it is just an example. The method is simple. It is a custom contract through the interface. Implementation of an object through COM

Unconstructive. Implementation inheritance through Adapter mode simulation.

The example is as follows:

'Interface part public function abstructfun () AS String

END FUNCTION

'You cannot create an object (used to implement abstract method) Set instancing to publicnocreatable

IMPLEMENTS IMYINTERFACE

Public Function ImyInterface_AbstructFun () AS STRINGIMYINTERFACE_ABSTRUCTFUN = "I get up" end function

'Implementation

IMPLEMENTS IMYINTERFACE

Public Function ImyInterface_AbstructFun () AS STRINGDIM AC AS New AbstructClassImyinterface_AbstructFun = Ac.Imyinterface_AbstructFun & "I have breakfast" end function

转载请注明原文地址:https://www.9cbs.com/read-27412.html

New Post(0)