.NET
  Home arrow .NET arrow Page 3 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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-4


    (Page 3 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 GetList operation.

       4.  Click Properties to open the UML Operation Properties dialog box,
            as shown in Figure 5-9.


    Figure 5-9.  UML Operation Properties dialog box

       5.  Select the Parameters category.

       6.  Click New to create a new parameter customerTypeID of data
            type VB::Integer (C#::int if you want to code in C#). Set the
            Kind to in, for in-going (read-only), as shown in Figure 5-10.


    Figure 5-10.  UML Operation Properties dialog box with the customerType ID parameter 

       7.  Click OK twice.


    Setting the parameter Kind to in indicates that it’s an in-going (read-only) parameter. When generating code for this class, you want this operation to be a method. You can tell VEA that the code generation engine must create this operation as a procedure (method) through the Code Generation Options of the UML Operation Properties dialog box. Exercise 5-5 shows how to make sure GetList is a method.


    EXERCISE 5-5

    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 GetList 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#, if you prefer) from the Target language list.

    7. Select Procedure from the Kind list. Your code generation settings should look like Figure 5-11.


    Figure 5-11.  UML Operation Properties dialog box with code generation settings 

       8.  Click OK twice.

       9.  Click the Preview code button to see what the generated code
            will look like, as shown in Figure 5-12. If you choose C# as the
            target language, the code generation preview will look like the
            code shown in Figure 5-13.


    Figure 5-12.  Code preview for the GetListoperation (VB code)


    Figure 5-13.  Code for the GetList operation (C# code)

    The operation will be generated as a public Function4 procedure, because you’ve specified that the procedure has a return value (it will be generated as a Sub5 procedure if it doesn’t return anything).

    CustomerStatus is an operation showing the customer’s online status. This operation will be a property of the class. To make sure the code generation engine generates it as a property, you can specify this in the UML Operation Properties dialog box. You’ll do this in Exercise 5-6.


    EXERCISE 5-6

    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 CustomerStatus 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#, if you prefer) from the Target language list.

    7. Select Property from the Kind list.

    8. Check the Create Get Method option. Your dialog box should look like Figure 5-14.

    9. Click OK twice.

    10. Click the Preview code button to see the code shown in Figure 5-15.


    Figure 5-14.  UML Operation Properties dialog box for the CustomerStatus operation


    Figure 5-15.  Code Preview for the CustomerStatus operation (VB code)


    In the UML Operation Properties dialog box (Figure 5-14), you can choose if you want to create Set or Get methods. A Set method allows you to set the property, and a Get method allows you to get/read the property. This particular property should be read-only, so you just need to check the Create Get Method option.

    As you learned earlier, operations can also be of type constructor or destructor. A constructor is responsible for setting an object to its initial state. In other words, a constructor is a method that is called when the object is created. (Class instantiation is another term for this.) In VB, the constructor is named New. Although you can call the operation anything you like in VEA, the constructor will always be called New, once the code is generated,6 so you might as well call it New in the first place, if you’re working with VB code. As noted earlier, in C#, a constructor is named after the class. In Exercise 5-7, you’ll specify that the New operation is a constructor.


    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

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT