VB.net implementation prototype of Abstract Factory

Source: Internet
Author: User

I just implemented the abstract factory model, but I just had a look. It is a encouragement for me to come to the Sun first.

 

The effect is:

 

There are not many codes written for each Class. Note that the VB.net syntax is different from the C # syntax. For example, the keyword overrides, inherits, and the difference in function return values, VB.net directly uses "=" to complete:

Createuser = new accessuser. The return keyword is used in the C # implementation.

In this way, the client code does not need to have specific database Metadata classes, but only needs to use the abstraction of these classes. Encapsulate the specific data access process. The client code is as follows:

Public class form1

 

Private sub button#click (byval sender as system. Object, byval e as system. eventargs) handles button1.click

 

Dim accessfactorytest as new accessfactory

Dim usertest as user

 

Usertest = accessfactorytest. createuser

Usertest. connectdatabase ()

End sub

 

Private sub button2_click (byval sender as system. Object, byval e as system. eventargs) handles button2.click

Dim sqlserverfactorytest as new sqlserverfactory

Dim sqlserverusertest as user

 

Sqlserverusertest = sqlserverfactorytest. createuser

Sqlserverusertest. connectdatabase ()

End sub

End Class

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.