.NET
  Home arrow .NET arrow Page 4 - 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 - EXERCISE 5-7


    (Page 4 of 13 )

    1. Open the UML Class Properties dialog box for the Customer class by double-clicking the class.

    2. Select the Operations category.

    3. Select the New operation.

    4. Click Properties to open the UML Operation Properties dialog box (see Figure 5-9).

    5. Select the Code Generation Options category.

    6. Select Visual Basic (or C#) from the Target language list.

    7. Select Constructor from the Kind list.

    8. Click OK twice.

    9. Click the Preview code button to see the code shown in Figure 5-16.


    Figure 5-16.  Code preview for the New constructor (VB code)


    A destructor operation is called when the class is destroyed. Well, at least in theory; it might not be called, depending on how the object was disposed of. In VB, the destructor will be generated as a method with the name Finalize. If you’re working with C#, it will be named after the class. In Exercise 5-8, you’ll specify that the Finalize operation is a destructor.7

    EXERCISE 5-8

    1. Open the UML Class Properties dialog box for the Customer class by double-clicking the class.

    2. Select the Operations category.

    3. Select the Finalize operation.

    4. Click Properties to open the UML Operation Properties dialog box (see Figure 5-9). 

       5.   Select the Code Generation Options category.

       6.   Select Visual Basic (or C#) from the Target language list.

       7.   Select Destructor from the Kind list.

       8.   Click OK twice.

       9.   Click the Preview code button to see the code shown in Figure
             5-17.


    Figure 5-17.  Code preview for the Finalize destructor (VB code)


    Notice in Figure 5-17 how the Overrides keyword is automatically added to the operation signature, because the operation is a destructor. All .NET Framework classes inherit from the Object base class, which has an overridable destructor, so you must override it; you cannot shadow it.8


    NOTE Please see your .NET Framework documentation for more information about the Finalize method, destructors, and garbage collection.

    Listing 5-1 shows the complete code generated for the Customer class. To generate the code, select UML -> Code -> Generate. In the Generate dialog box (shown earlier in Figure 5-2), choose Visual Basic as the target language, select the Customer option, specify the path as \EDWVSNETUMLMSF\Chapter 05\, and click OK.

    Listing 5-1. Code Generated for the Customer Class

    1 Namespace MyNamespace
    2
    3   Public Class Customer
    4
    5     Public Name As String
    6
    7     Public Address As String
    8
    9     Public Function GetList (ByVal customerTypeID As 
            Integer) As Object
    10
    11    End Function
    12
    13    Public ReadOnly Property CustomerStatus () As Boolean
    14         Get
    15
    16         End Get
    17
    18     End Property
    19
    20     Public Sub New ()
    21
    22     End Sub
    23
    24     Protected Overrides Sub Finalize ()
    25
    26     End Sub
    27
    28   End Class
    29
    30 End Namespace

    Now that you’ve seen how the packages and classes elements of class diagrams work, we’ll look at the final element of these diagrams: relationships.

    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

    - 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...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT