Based on the component. NET software development (5)

Source: Internet
Author: User
Tags implement object model
Actual combat:
Create a vb.net Windows application: Vbtestdynamiccomponent. Add the two classes Componentlist and LoadComponent described earlier to the project.

We read the relevant assembly information and class name information from the configuration file at the start of the program, and add the following code to the Form_Load procedure for the main form:



The Private objloadcomponent as LoadComponent

Private Vbobj as Object

Private Componentreader as Mycomponentlist

04

The Private Sub vbtestdynamicform_load (...) Handles MyBase.Load

Objloadcomponent = New loadcomponent ()

Modified Componentreader = New mycomponentlist ("Componentlist.xml")

The Dim filename as String

The Dim classname as String

Ten Componentreader.beginread ()

filename = componentreader.getfilename (0)

classname = componentreader.getclassname (0)

DIM ret as Boolean

ret = objloadcomponent.loadcomponentlibrary (filename)

Vbobj = Objloadcomponent.loadclass (classname)

Vbobj.show ()

End Sub

We see that the 07--10 sentence removes the DLL file name and class name from the configuration file. The 11th and 12 sentences get the first DLL file name and class name, then load the component library in the 14th sentence, and the 15th sentence to load the object, because the returned object is actually a form, so you can call show () directly in the 16th sentence. method to display this form.

As you can see from your code, it's easy and easy to create objects dynamically in. NET! Please note: In engineering we don't even need to add a reference to a particular component to the project! The object created dynamically in this example is a form, and the Form object is available by default. In real engineering, you can put all the interfaces into a specific DLL, I call it "façade Assembly", and other projects just reference this DLL, then all the components that implement these interfaces can be created freely by name!

Summary
We introduced it in a short essay. NET's hybrid language development features and dynamic assembly component technology, demonstrated in the. NET, the simplicity and flexibility of developing component-based application software provide new possibilities for us to develop "embrace change" software system, which can be summarized as follows:

(1) We can divide the system function by the Ooad (object-oriented analysis and design) before the development. It is then allocated to different developers to develop multiple DLLs, and finally easily combine these components to construct a new system that, once made into a component, can be reused in future projects. Fewer bugs, more functions, more stability, and such components will be invaluable technical resources.

(2) as a result of. NET powerful Component Object model, which originally applied to the source code level of some object-oriented features: such as inheritance and polymorphism, can now be extended to the component level. In particular, we can now apply design patterns between components.

Comrades, hurriedly go to turn over the classics of Gof, the above 24 kinds of mode apply in the component, you will be deeply feel the software technology progress to the programmer to bring the broad scope of the room.

(3) by saving the configuration information externally, we can dynamically let the whole software show a completely different style and function without recompiling the program. Think that if the two forms created in our example are the main form of another two complex programs, does that mean our programs can easily integrate them? Is it too easy to implement, adding one or two lines of code to the configuration file?

(4) The configuration file uses the XML standard, can easily add new attributes for the element, thus expands the function of the program. In addition, by providing a DTD and schema, you can verify that the file is valid before dynamically loading the configuration file, and that XSLT can dynamically replace the configuration file ..., XML flexibility and scalability I don't need to say much, do I? This flexible application depends on you!

(4) With the above technical support, we develop software in the process of focus on the ooad above, which is reflected in the object-oriented ERA system analysis and design is more important than the characteristics of the code.

For example, a software company needs to develop a product in an industry, it can analyze the business functions of the industry in detail, abstracting different levels of business, where the most basic business is made can dynamically load components. When you need to customize software for a new customer in this industry, you can greatly improve development efficiency by assembling existing basic business components and then developing a small number of specialized components. This is CBD (component-based Develop: component-based development).

Currently very popular MDA (Model driven architecture), in fact, is based on components, not a large number of stable components to do support, MDA is "Drive" not up.

The author found that all successful software companies, in particular, the first-class multinational companies, such as CA, SAP, Ericsson, and its internal has a large-scale component library, the components in the library have been rigorous practice test, based on the existing mature components to develop a new system, the code reuse rate can reach 80% to 90%, To achieve this code reuse degree, the need for software enterprises to go into a certain industry for several years more than 10 years or even decades of deep accumulation, this is the young domestic software companies and foreign first-class enterprises in the gap.

(5) ...

Well, no more, believe that smart readers can appreciate the power of component development.

Back to. NET, Microsoft, in advertising to Vs.net, said: It greatly improved the efficiency of development. This is not bragging, I personally feel that use. NET development project, compared with the traditional WIN32 platform technology, the development efficiency can be increased by 1/3! Real deep learning and application. NET, the author can not help the development and design. NET technology scientists and engineers admire and greet their creative work. At the same time, I also hope that China's software technology can catch up, we really lag too much!







Related Article

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.