18.8. Code Generation and Refactoring

One of the core goals of Visual Studio 2008 and the .NET Framework is to reduce the amount of code that developers have to write. There are two ways this goal is achieved: either reduce the total amount of code that has to be written or reduce the amount that actually has to be written manually. The first approach is supported through a very rich set of base classes included in the .NET Framework. The second approach, reduce the amount of code that is written manually, is supported by the code generation and refactoring tools included with the Class Designer.

18.8.1. Drag-and-Drop Code Generation

Almost every action performed on the class diagram results in a change in the underlying source code, and essentially provides some level of code generation. We've already covered a number of these changes, such as adding a property or method to a class in the Class Details window. However, there are some more advanced code generation actions that can be performed by manipulating the class diagram.

As we explained earlier in the chapter, you can use the inheritance connector to establish an inheritance relationship between a parent class and an inheriting class. When you do this, the code file of the derived class is updated to reflect this change. However, when the parent class is abstract, as in the case of the Product class in Figure 18-7, the Class Designer can perform some additional analysis and code generation. If the parent class is an abstract ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.