Visual Studio Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Visual Studio Hacks [Electronic resources] - نسخه متنی

Andrew Lockhart

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 82. Generate UML Design Documents from Code

Use Visual Studio to generate design documents
in Visio.

Like all good developers,
you keep your design documentation up-to-date, right? Most likely,
that's a no. After all, who wants to constantly go
back and continuously update design documents while coding? Most
developers I know usually don't have the time
because they are too busy trying to get the application implemented.

To help with this task, you can use Visual Studio to generate those
pesky design documents, in particular the class diagrams, by having it reverse
engineer your code. Although it won't replace and
update all of your design documents, it can cut down on the amount of
time it takes to maintain them manually. Essentially, this hack is
the opposite of [Hack #81].


10.7.1. Reverse Engineer Your Code


To get started, you first need to create a
Visual Studio Project. This can be any type of project, and most
likely it's one that you've been
working on or have already created. In this hack,
I'm going to use the
VehicleLibrary example found in
[Hack #81]. To refresh
your memory, the Solution Explorer of that project can be seen in
Figure 10-40.


Figure 10-40. VehicleLibrary project in the Solution Explorer

To reverse engineer the code for this project, do the following:

Click Project Visio UML Reverse Engineer.

Browse to the location where you want your Visio file to be saved,
give it a name, and click Save.

Depending on the size and complexity of your project, the reverse
engineering process may take a moment or two.

Once your code has been successfully reverse engineered, an instance
of Visio is automatically started. You can see in the Model Explorer
that your classes have been automatically created (see Figure 10-41).


Figure 10-41. Classes automatically generated in Visio

You can also see in your Visual Studio instance that the generated
Visio file has been added to your project under the Solution Items
folder.


10.7.2. Create Your Class Diagram


Unfortunately,
that's as far as the
reverse engineering will take you. You'll have to
create the class diagram manually. Depending on the size of your
class hierarchy, this may or may not be a big deal. The positive spin
to this is that Visio is smart enough to understand the relationships
between the generated classes.

For instance, when you drag your classes onto a diagram, Visio
automatically determines their relationships and draws the
generalization lines for you. An example is shown in Figure 10-42.


Figure 10-42. Dragging classes onto a Visio diagram

As I was dragging classes from the Model Explorer onto a static
structure diagram in Visio (see Figure 10-42), all
the arrowed lines were drawn for me. I didn't have
to remember all the relationships between the classes, which in this
case happen to be inheritance lines.

So as you can see, Visual Studio can be used to reverse engineer your
classes from code into Visio for use on class diagrams, sequence
diagrams, and other related design documents.

Dave Donaldson


/ 172