Building Components

When we are actually making our Visual Basic project, we will use components. Components are simply sections of precompiled code relating to a specific topic - for example creating a new customer or adding an order. Because a component is precompiled, it does not matter what programming language it was created in. During the course of the project, we will be using components that are already built, such as a text box or a form, and other components that will have to be built from the beginning, such as the customer or order components. When we have to build our own components, we will use one or more Visual Basic classes to make the component. For example, we could build a customer component from two classes arranged in a hierarchy. The bottom class will contain the properties for the component. The middle class will manage the bottom class by retrieving instances of the bottom class and providing methods to create new customers, delete customers, etc. These two classes will be joined together to create a customer component. When the application is running, this component will allow you to retrieve, add or delete customers, and also to get or set information on a customer.

When we build an object, we should consider it as making a contract. This contract says what services (methods) the object will provide, what properties are available for reading (that is, which properties we can get the values of), and what properties are available for writing (that is, which properties we can set). The contract will also state if there are special conditions for reading and writing properties, such as only having write privileges when adding a new object. When making objects, the contract is officially signed when the classes are compiled into a component. Once the contract is signed, we agree not to change any of the existing properties or methods.

Unofficially, the contract is created when the design of the component is created. Once the design is complete, and the methods and properties of the component are determined, other components will be designed and built based on this design.

If you should change any of the methods or properties after the design is complete, you will have to redesign and rebuild all of the components that use the redesigned component. Even worse, if you change the component after it is compiled, you will have to un-register the original component, register the new version, and make all the changes to the dependent components. Both of these scenarios could take days or weeks of work, putting the project behind schedule and budget. This is why we should view the design of our components as a contract. The way to make sure we can honor the object contracts is by carefully designing our components.

Was this article helpful?

0 0
365 Days Of Motivation

365 Days Of Motivation

Stop Wasting Time And Learn How To Stay Motivated. Finally! Discover How To Stop Your Mind From Wandering, And Upgrade Your Motivation. You Can Hack Your Motivation Levels, Allowing You To Take Your Life To The Next Level.

Get My Free Ebook

Post a comment