UML to CSharp module

This generator is written to generate a basic backend system according to the Domain Driven Design principles, published by Eric Evans in his book “Domain Driven Design - Tackling Complexity in the Heart of Software”.

The base model is a UML1.4 class model. A number of stereotypes, tags and assumptions are used for the generation towards C# 2.0, NHibernate v1.2 mapping files, SQL Server DDL and Visual Studio 2005 project and configuration files.

Demonstration

This demo provides a quick tour of the UML to CSharp generative module..

Presentation

Target Architecture

The image below depicts the application architecture towards which the UML model is generated.

Domain model

The sections below briefly explain the transformations from UML to the elements of the target architecture.

Source element Target element
UML Model
  • Domain model package
  • Common repository interface (IRepository.cs)
  • Visual Studio 2005 project file
  • Visual Studio 2005 assemblyinfo file
Root package with stereotype “domainModule”
  • DomainModel.[DomainModuleName] namespace & package
Class with stereotype “entityObject”
  • Regular C# class
  • NHibernate mapping file
  • if tagged value “isAggregateRoot” equals true, then a repository interface for this class
Class with stereotype “valueObject”
  • Regular C# class
Class with stereotype “enumeration”
  • C# enum, with enumerated values equal to the UML class’ attributes and initial values

Domain Persistence Implementation

Source element Target element
UML Model
  • Domain Persistence Implementation package
  • Implementation of IRepository.cs
  • Visual Studio 2005 project file
  • Visual Studio 2005 assemblyinfo file
Root package with stereotype “domainModule”
  • DomainPersistenceImplementation .[DomainModuleName] namespace & package
Class with stereotype “entityObject”
  • if tagged value “isAggregateRoot” equals true, then an implementation of the repository interface for this class
  • if tagged value “isAggregateRoot” equals true, then a factory for this class

Resource Layer

Source element Target element
UML Model
  • SQL Server DDL

Any Client

Source element Target element
UML Model
  • PresentationConsoleUI package
  • Visual Studio 2005 project file
  • Visual Studio 2005 assemblyinfo file
  • Application configuration file
  • NHibernate helper file
  • Main program file
Class with stereotype “entityObject”
  • if tagged value “isAggregateRoot” equals true, then an operation with very basic console interaction to fill the individual attributes and an operation to display individual attributes

Overall

Source element Target element
UML Model
  • Visual Studio 2005 solution file

The SalesAdministration example

This generator comes with a simple UML model example, called SalesAdministration, stored in the default.uml14 file. This file can be used as a source to generate all the elements listed above. In the generation, a few assumptions are made as to the location and/or existence of certain resources.

These are:

  • The configuration files assume that relative to the folder with the SalesAdministration.sln solution file, there is a folder one level up, called “NHibernate_v1.2” containing all NHibernate 1.2 files (most importantly containing the “bin” folder). Here’s an example of the assumed folder structure:
    [My Documents]\Visual Studio 2005\Projects
                    NHibernate_v1.2
                            bin
                            …
                    SalesAdministration
                            DomainModel
                            …
                            SalesAdministration.sln
                            
    
  • There is a SQL-Server database called SalesAdministration. If there’s not: create one. On that database, the generated DDL file can be run.

Planning

Module status
Domain models

100%

Persistency

100%

Resource Layer

100%

Configuration files

100%

Installation

The installation is described on the installing modules page .

Webdesign : www.katrinet.com - Realisation : Obeo