.NET
  Home arrow .NET arrow Page 5 - The Basics
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

The Basics
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 19
    2005-04-06

    Table of Contents:
  • The Basics
  • Modeling a Logon Process
  • Coding Conventions
  • Generating the VB .NET Code for the Logon Class
  • Generating the C# Code for the Logon Class
  • ER and ORM Diagrams
  • Generating the Database
  • Reverse Engineering a Database

  • 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


    The Basics - Generating the C# Code for the Logon Class


    (Page 5 of 8 )

    Now that you have modified the Logon class for C#, it’s time to see the code that VEA generates from the model. Exercise 1-8 shows how to generate the C# code.

    EXERCISE 1-8

    1. Select the Logon class.

    2. Select UML -> Code -> Generate. This brings up the Generate dialog box.

    3. Make sure C# is selected in the Target language list.

    4. Select the Logon class in the Select classes for code generation tree view.

    5. Select the location you want the generated output placed in by typing the path in the Location text box or by browsing to the location after clicking the Browse button. Save the output with this name and path for easy access in later exercises and chapters: \EDWVSNETUMLMSF\ Chapter 01\C#\TopPackage\Logon.cs.

       6.  Click OK. You might be prompted to create a nonexistent folder. 
            If so, click Yes.


    Let’s take a look at the generated C# code. Go to the output location you specified in the Generate dialog box and double-click the Logon.cs file. The code file is now opened in the VS .NET IDE, and it should look like the one shown in Figure 1-10.


    Figure 1-10.  The generated C#code for the Logon class

    Figure 1-10 shows the generated output for the Logon class from the UML model as C# code.

    Code Generation Summary

    As you’ve seen from the previous exercises, the code generated by VEA is nothing more than a skeleton of the class(es) you have in your UML model. However, you can add significantly more to your diagrams and have it reflected in the generated code. Specifically, we’re thinking about documentation here, in the form of comments in the code, initial attribute values, visibility, scope, multiplicity in the form of collections and arrays, and so on.

    Modeling a Database

    The Logon class you created in the previous section needs to do some database lookup in order to validate the user that is trying to log on. Therefore, you need a database, which you’ll be modeling in this section. In standard UML, you normally model a database as a class diagram, giving it a Table stereotype. (We’ll talk more about stereotypes in later chapters.) VEA doesn’t support the generation of Data Definition Language (DDL) scripts from class diagrams, which means you can’t do it that way. However, VEA (and the standard versions of Visio) has a perhaps better way of dealing with databases: the database model diagram.

    Creating the Database Model Diagram

    VEA offers database modelers several options, including entity-relationship (ER) and Object Role Modeling (ORM) diagrams. However, in this book, we’ll be using the database model diagram.


    This article is excerpted from Enterprise Development with Visual Studio .NET, UML, and MSF by John Erik Hansen and Carsten Thomsen (Apress, 2004; ISBN 1590590422). Check it out at your favorite bookstore today. Buy this book now.

    More .NET Articles
    More By Apress Publishing


     

    .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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek