Preparing Your Project for Distribution

What Is an Object?

Objects, which are derived from classes, are encapsulations of data and code; that is, an object comprises both its code and the data it uses. For example, say you need to keep track of employees in an organization, and that you need to store a number of pieces of information for each employee, such as Name, Date Hired, and Title. Consider also that you need methods for adding and removing employees, and you want all of this information and functionality available to a number of different applications in different departments within your organization (possibly even across platforms). You could write the necessary code to do all of this in each and every application throughout your organization, but this approach would be difficult and inefficient to implement and an absolute nightmare to maintain. A better approach is to take advantage of object-oriented programming by encapsulating all of the employee data and functionality (adding and deleting code for example) into a single, reusable object. Once the object is created and tested, all of the different applications involved could work with the employee data through a consistent interface the employee object's interface.

The encapsulation of data and code is the fundamental idea of objects. By encapsulating the data and the code that manipulates the data into a single object, end-user applications are freed from the intricacies of data maintenance. For example, suppose company policy changed such that when a new employee is added to the system, a special tax form needs to be printed. If the data and associated code weren't encapsulated in a common object, you would need to modify each and every application that contained code to create a new employee record. By using an object, you need to change the code in only one location (within the object), and as long as the interface of the object (its properties, methods, and events) wasn't changed, all of the applications that use the object to create a new employee would instantly have the policy change in effect.

Note

If you're not currently designing your own classes to be used to instantiate objects, some of the material in this chapter might not make much sense to you. In this case, I highly recommend that you purchase a book specifically focused on object-oriented programming in Visual Basic .NET.



Practical Standards for Microsoft Visual Basic. NET
Practical Standards for Microsoft Visual Basic .NET (Pro-Developer)
ISBN: 0735613567
EAN: 2147483647
Year: 2005
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net