Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
Overview
The previous chapter discussed the basics of Windows Forms 2.0. These capabilities are sufficient for straightforward user interfaces for systems written in VB 2005, along with the built-in capabilities of forms and controls available in Windows Forms 2.0.
However, as applications become larger and more complex, it becomes more important to use the advanced capabilities of the .NET environment to better structure the application. Poorly structured large systems tend to have redundant code. Repeated code patterns end up being used (in slightly different variations) in many, many places in an application, which has many bad side effects-longer development time, less reliability, more difficult debugging and testing, and tougher maintenance.
Examples of needs that often result in repeated code include making sure that fields are entered by the user, that the fields are formatted correctly, and that null fields in the database are handled correctly. Proper object-oriented design can encapsulate such functionality, making it unnecessary to use repeated code.
In VB6 and earlier systems, the techniques available to reduce redundant code were limited. You could write functions to be accessed from various places, for example, and you could write UserControls to encapsulate some functionality.
Your options in Visual Basic 2005 are much broader. Using the full object-oriented capabilities of the .NET environment, plus additional capabilities specific to Windows Forms programming, you can componentize your logic, allowing the same code to be used in numerous places in your application.
This chapter discusses techniques for componentizing code in Windows Forms applications. It is assumed that you have already read Chapters 3 and 4 on inheritance and other object-oriented techniques available in .NET before working with this chapter.
Категории