.NET
  Home arrow .NET arrow Page 10 - Examining the UML Models: Static Models
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Examining the UML Models: Static Models
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 11
    2005-04-20

    Table of Contents:
  • Examining the UML Models: Static Models
  • Classes
  • EXERCISE 5-4
  • EXERCISE 5-7
  • Relationships
  • Generalization Relationship
  • States
  • Components
  • Dependencies
  • Code Generation from a Component Diagram
  • Nodes
  • Stereotypes
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Examining the UML Models: Static Models - Code Generation from a Component Diagram


    (Page 10 of 13 )

    If you generate code from your component diagram alone, you can generate code for only the interfaces, not the components. This is very logical if you think about it, because the components on your component diagram just represent the physical file containing the classes and interfaces.

    To generate code for your interfaces, select UML -> Code -> Generate. You can choose which model elements to generate code for from the Generate dialog box. Figure 5-31 shows the Generate dialog box set for generating code for the _Imageshrink interface to the \EDWVSNETUMLMSF\Chapter 05\ path.

    After clicking OK in the Generate dialog box, you can open the code file in VS .NET (or any text editor, like Notepad, for that matter) from the path you’ve just specified. Figure 5-32 shows the _Imageshrink.vb file generated for the _Imageshrink interface using the settings in Figure 5-31.


    Figure 5-31.  Generate dialog box with the _ImageShrink interface selected


    Figure 5-32.  VB code generated for the _Imageshrink interface 

    However, generating code for interfaces alone doesn’t make much sense if your interface is connected to one of your own classes. It’s more relevant to generate code for the class that incorporates the interface. In Exercise 5-19, you’ll create a new class diagram with the Class1 class and incorporate the _ImageShrink and ObjectControl interfaces described in the previous section. Then you’ll generate the code for that class.


    EXERCISE 5-19

       1.  In VEA, create a class diagram named ClassInterfaceDiagram.

       2.  Add a class named Class1 to the diagram.

       3.  Add the _Imageshrink interface to the diagram, attaching it to
            Class1. You can copy the interface from the
            MyComponentDiagram diagram you created in the previous 
            exercises.

       4.   Add an interface named ObjectControl to Class1.

       5.   Double-click the ObjectControl interface to open the UML
             Interface Properties dialog box, and then select the Operations
             category.

       6.   Add three operations to the ObjectControl interface named
             Activate, Deactivate, and CanBePooled. (See Exercise 5-
             18 for instructions on how to add the operations.) Your diagram
             should  now look like Figure 5-33.  
    Figure 5-33.  Class diagram with Class1 class incorporating the ObjectControl and _imageshrink interfaces


       7.  Double-click Class1 to see its properties, as shown in Figure 5-
            34. As you can see, Class1 doesn’t have any operations. All the
            operations shown in Figure 5-33 are implemented from the
            interfaces. Click Cancel to close the dialog box.

        8.  Select UML -> Code -> Generate. In the Generate dialog box,
             select only Class1 in the tree view, and then click OK. Your
             generated code will look like the code in Figure 5-35.



    Figure 5-34.  UML Class Properties dialog box for Class1, showing the class does not have any operations


    Figure 5-35.  Code generated for class1 including interfaces

    as you can see, the code listed in Figure 5-35 makes more sense than the code listed in Figure 5-32. The code in Figure 5-35 shows how the class implements the interfaces and that the Shrink operation is automatically generated.

    Deployment Diagrams

    The component diagram shows how the components are physically grouped and implemented. A deployment diagram takes this a step further and shows how the hardware and software elements of your solution will be configured and implemented. You can see how your components will be implemented in the runtime environment. As a rule of thumb, each UML model should contain only a single deployment diagram showing how the solution will look like from a runtime point of view.

    A deployment diagram basically consists of three elements:

    • Nodes

    • Components

    • Relationships

    Figure 5-36 shows elements in a deployment diagram, as discussed in the following sections.


    Figure 5-36.  Deployment diagram with two different node types

    More .NET Articles
    More By Apress Publishing


     

    Buy this book now. This article is excerpted from Enterprise Development with Visual Studio .NET, UML, and MSF written by John Erik Hansen and Carsten Thomsen (Apress, 2004; ISBN: 1590590422) Buy this book now.

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek