Building the Business Logic Layer in Visual Basic 2005
If you have class, you've got it made. If you don't have class, no matter what else you have, it won't make up for it.
If you have classes in your application, you've got it made. If you don't have classes, no matter what else you have, it won't make up for it. Classes are central to development in .NET.
In fact, it is difficult to build a .NET application without using classes. If you added a form to your project, you have already created a class. A form is just a class that inherits from the .NET Framework System.Windows.Forms.Form class, which gives the class the attributes and behaviors of a form.
In the preceding chapter, you saw how to use classes to build the user interface layer. This chapter shows you how to build classes for the business logic layer.
This chapter covers the fundamentals of creating classes and defining properties and methods. It also details more advanced topics such as using generics and building a base business object class. The Purchase Tracker sample application is used to demonstrate these techniques.
What Does This Chapter Cover?
This chapter demonstrates the following techniques:
- Creating a class
- Documenting the class with XML comments
- Adding exception classes to your class file
- Defining properties
- Defining property accessibility
- Understanding generics
- Handling Nullable types
- Defining methods
- Passing parameters ByVal or ByRef
- Overloading methods
- Marking methods as obsolete
- Creating a base business object class
- Overriding base class members
This chapter covers the basics of how to create a class and then builds on those basics to detail some of the new Visual Basic 2005 features such as XML comments and generics. If you have already been doing object-oriented programming in Visual Basic, you already know the basics. But if you want to "build along" as you read through this book, work through the basics before moving on to the more advanced features later in this chapter.