Chapter 5: Class Modeling Using Class Designer


Overview

In this chapter, we'll look at Class Designer, which provides a design surface for visualizing the classes and other types that you define in code. Looking at it from that perspective, Class Designer provides an up-to-date window on the code, thanks to automatic synchronization. Conversely, this designer enables you to define your class structure diagrammatically prior to using the code editor. If you have a background in UML, you will recognize this as the raison d'tre for a class designer.

We'll look at Class Designer from both angles — visualization of existing code and design of new type hierarchies.

In the section headed "From Code to Class Diagrams," we introduce class diagrams as a pictorial way of representing code. For continuity, we draw on the running StockBroker example for inspiration, and to provide a code base. We invite you to retrofit some new ideas into that example, but that's not compulsory and you'll learn a lot simply by reading that section.

In the section headed "From Class Diagrams to Code," we show how class diagrams should be used to drive the high-level design and overall structure of your code, rather than as a convenient mechanism for documenting it after the event. In that section, we take each of the modeling concepts — such as inheritance and association — in turn.

We'll use the Visual Basic .NET Class Designer to introduce the notation and to demonstrate the main features in a consistent manner. Keep in mind that the majority of the features are equally applicable to Visual C# and Visual J# as well as Visual Basic, and indeed we'll use C# toward the end as a vehicle for introducing some more advanced ideas. Unfortunately, C++ is not supported by this first version of Class Designer.

As you read this chapter, you should be aware of the distinction between the terms type and class. By type we mean any type supported by Class Designer, such as a class, an interface, a structure, or a delegate. By class we mean specifically the class type, though discussions about classes may well apply to some of the other types too. This distinction between the terms used is important because Class Designer could be regarded in a wider sense as a "Type Designer" not limited to class design, although the term Type Designer would be less familiar to the object modeling — and especially UML — community.

Important

Provided Files: You will find the sources files and class diagrams for this chapter in a solution contained within the StockBrokerClassLibrary.zip file provided on the book's Website. That will be useful to you as a reference point and a quick route through the chapter, though of course we encourage you to take the time to build the examples yourself from scratch.



Professional Visual Studio 2005 Team System
Professional Visual Studio 2005 Team System (Programmer to Programmer)
ISBN: 0764584367
EAN: 2147483647
Year: N/A
Pages: 220

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