Sie sind auf Seite 1von 40

 

.NET Application Modeling 
Language (nAML) 
V1.0 (Beta 1) Specification, Examples and Tools 
 
Mohammad Ashraful Alam, Microsoft MVP 
 
 
 
 
 

 
   
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 
Page intentionally left blank.   

Page | 2

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

License 
You are free to copy, distribute and display this book. However please include my name “Mohammad
Ashraful Alam” while referring any content of this book.

Page | 3 Issue Reporting 
This specification is in Beta 1 stage currently. Please have your valuable inputs to be sent to the
following email to make it better.

Mohammad Ashraful Alam – ashraf@mvps.org

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Table of Contents 
License ........................................................................................................................................................... 3 
Issue Reporting ............................................................................................................................................. 3 
nAML: Specification ...................................................................................................................................... 6 
Page | 4
Introduction .............................................................................................................................................. 6 
Terms and Definitions ............................................................................................................................... 6 
Element: ................................................................................................................................................ 6 
Operation: ............................................................................................................................................. 6 
Association ............................................................................................................................................ 7 
Attribute ................................................................................................................................................ 7 
Element Lifeline .................................................................................................................................... 7 
Common Semantic Guideline ................................................................................................................... 8 
Web User Interface Sample: The Hello World! ............................................................................................. 9 
C# Samples .................................................................................................................................................. 11 
Block Statement ...................................................................................................................................... 11 
If Condition .............................................................................................................................................. 12 
Compound If Condition ........................................................................................................................... 13 
Try/Catch Block ....................................................................................................................................... 14 
While Loop .............................................................................................................................................. 15 
For Loop .................................................................................................................................................. 16 
Nested For Loop ...................................................................................................................................... 17 
Method Call and Return .......................................................................................................................... 18 
SQL Samples ................................................................................................................................................ 20 
SQL Create Table ..................................................................................................................................... 20 
SQL Alter Table: Add Column .................................................................................................................. 21 
SQL Alter Table: Alter Column ................................................................................................................ 22 
SQL Alter Table: Drop Column ................................................................................................................ 23 
SQL Drop Table ........................................................................................................................................ 24 
SQL Select ................................................................................................................................................ 25 
SQL Where .............................................................................................................................................. 26 
SQL Insert ................................................................................................................................................ 27 
SQL Update ............................................................................................................................................. 28 

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Delete ............................................................................................................................................... 29 
SQL Inner Join.......................................................................................................................................... 30 
SQL Left Outer Join .................................................................................................................................. 31 
SQL Union ................................................................................................................................................ 32 
Page | 5
SQL Insert‐Select ..................................................................................................................................... 33 
SQL Where‐Select ................................................................................................................................... 34 
Tools and Tutorial ....................................................................................................................................... 35 
Appendix: Common Attributes ................................................................................................................... 38 
 

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

nAML: Specification 
Introduction 
nAML (.NET Application Language, pronounced as “namel”) is a visual modeling semantics to model
.net applications with wide range of specific details. It contains extremely power visual notations and
Page | 6 semantics to illustrate complex application components, processes and operations easily. It overcomes
the limitation of traditional modeling languages by providing a single space to describe an application
system with its structural and behavioral, as well as physical and logical components. One of it’s the
most powerful objectives is nAML requires near to zero knowledge on notation semantics to
understand an application system from readers perspective.
Example: Using nAML, for instance, a software architect can model a whole or part of a web
application in a single visual diagram with respect to interaction, communication and structure
between end user, web interface, .net classes, database objects, physical tiers (web server, business
logic server, database server etc) and so on.
The primary objectives of nAML can be considered as follows:
• Provides a single space to visually describe one or more application systems with structural
and behavioral components.
• Provides a single space to visually describe one or more application systems with logical and
physical components.
• Provides a single space to visually describe one or more application systems from top to low
level.
• Provides a single space to visually describe a part or whole of one or more application
systems.
• Extremely simple and easy understand and learn from readers and designers perspective.
• Concentrates on .NET applications, with its related logical and physical entities (user interface,
application logic, business logic, database etc).

Terms and Definitions 
Element:  
Definition: An Element is a structural notation that is the physical or logical object that holds one or
more physical and/or logical objects.
Notation:

Example: In an ASP.NET web application, an ASP.NET page can be an Element, having controls
embedded within it as sub-Element and the event handler methods as defined Operation within it. For
a .net class, the member Elements are the properties, data fields etc. For a physical database, its
member Elements is the tables.

Operation:  
Definition: An Operation is a behavioral notation that is the set of one or more actions to be performed
that are defined in an Element.
Notation:

Or

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Example: For instance, an ASP.NET page code behind class, as an Element, can have controls event
handlers (click event handler of button etc) as Operation. For a .net class, the members Elements are
the methods etc. For a physical database, its “Operation” can be defined within the stored procedure,
functions.
Page | 7
Association 
Definition: Association is a structural notation that illustrates how the Elements or Operations are
connected to other Elements or Operations.
Notation:

Attribute 
Definition: Attribute is a structural notation that is the Meta data information that describes an
Element, Operation or Association.
Notation:
The notation of attribute can be simple text or a visual notation of an Element, Operation to be
expressed as characteristics of another Element or Operation.
Example: For a .NET class “Employee” can have an Attribute as,
Class Name: Employee

Element Lifeline 
Definition: An Element lifeline is a behavioral notation which is the time span within which all activities
related to the corresponding Element is illustrated. The life line also shows the active and inactive
state of the Element. Each lifeline for a given Element applies to only one instance of that Element.
Notation:

Example: If an instance of a .net class is being created, then its activation will be illustrated from the
moment it created.

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Common Semantic Guideline 
• To distinguish structural and behavioral components of system, consider solid line diagrams as
the behavioral component and dashed line diagrams as the structural component.
• Element Lifeline reflects the time span for behavioral components only, rather structural
components

Page | 8    

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Web User Interface Sample: The Hello World! 
The sample illustrated below shows the “Hello World” message in an ASP.NET Label server control,
when a user clicks on a ASP.NET Button server control.

Page | 9 End User UI: default.aspx


Type:
System.Web.UI.Page
Location: /default.aspx

UI: Button
Text: Chick Here
Clicks ID: btnHelloWorld
Type: Belongs to
System.Web.UI.WebContro
ls.Button

Belongs to

C# Method: btnHelloWorld_Click

Parameter: sender
Parameter name: sender
Parameter type: object
Parameter value: Calls
btnHelloWorld

Parameter: e
Parameter name: e
Parameter type:
System.EventArgs

lblMessage.Text = "Hello
World!";

UI: Label
Text: Hello World Belongs to
Type:
Sees System.Web.UI.WebContro
ls.Label

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Now let’s see the corresponding nAML notations implemented in this example. 

Page | 10

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

C# Samples 
Block Statement 
Code Sample

Page | 11 if (age > 18)


{
discount = 0.1f;
category = "adult";
}
else
{
discount = 0.01f;
category = "under 18";
}

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

If Condition 
Code Sample

if (age < 18)


discount = 0.1f;
else
Page | 12 discount = 0.01f;

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Compound If Condition 
Code Sample

if (age > 10 && age < 18)


discount = 0.1f;
else
Page | 13 discount = 0.01f;

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Try/Catch Block 
Code Sample

try
{
throw new Exception("ERROR!");
Page | 14 }
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("IN FINALLY BLOCK!");
}

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

While Loop 
Code Sample

int i = 0;
while (true)
{
Page | 15 Console.WriteLine("Hello World");
i++;
if (i > 10) break;
}

nAML Illustration

i=0

while

true

Console.WriteLine(“Hello World”);

No

i=i+1

if

i == 10

Yes

break

End loop
 

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

For Loop 
Code Sample

for (int i = 0; i < 10; i++)


Console.Write("*");

Page | 16
nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Nested For Loop 
Code Sample

for (int i = 0; i < 10; i++)


{
for (int j = 0; j < i; j++)
Page | 17 Console.Write("*");
Console.WriteLine();
}

nAML Illustration

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Method Call and Return 
Code Sample

class SimpleMethodTesterClass
{
public static void TesterMethod()
Page | 18 {
float discount = SimpleMethodSampleClass.GetDiscount(21);
Console.WriteLine("You got discount: " + discount * 100 + " %");
}
}

class SimpleMethodSampleClass
{
public static float GetDiscount(float age)
{
if (age < 18)
return 0.1f;
else
return 0.01f;
}
}

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 
nAML Illustration

Page | 19

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Samples 
SQL Create Table 
Code Sample

Page | 20 CREATE TABLE [dbo].[tblUser](


[UserId] [int] NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[UserPassword] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_tblUser] PRIMARY KEY CLUSTERED
(
[UserId] ASC
)
)

nAML Illustration

CREATE

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(50) No No

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Alter Table: Add Column 
Code Sample

ALTER TABLE tblUser


ADD UserEmail nvarchar(50) default null

Page | 21 nAML Illustration

ALTER

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(50) No No

ADD COLUMN

Field name Field type Allow null Primary key

UserEmail nvarchar(50) No No

FORMS ALTERED TABLE AS

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(50) No No

UserEmail nvarchar(50) No No

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Alter Table: Alter Column 
Code Sample

ALTER TABLE tblUser


ALTER COLUMN UserPassword nvarchar(100) null

Page | 22 nAML Illustration

ALTER

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(50) No No

ALTER COLUMN

Field name Field type Allow null Primary key

UserPassword nvarchar(100) No No

FORMS ALTERED TABLE AS

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(100) No No

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Alter Table: Drop Column 
Code Sample

ALTER TABLE tblUser


DROP COLUMN UserEmail

Page | 23 nAML Illustration

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Drop Table 
Code Sample

DROP TABLE tblUser

nAML Illustration
Page | 24

DROP

Table: tblUser

Field name Field type Allow null Primary key

UserId int No Yes

UserName nvarchar(50) No No

UserPassword nvarchar(50) No No

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Select 

Code Sample

SELECT UserId, UserName, UserPassword


Page | 25 FROM tblUser

nAML Illustration

SELECT

Table: tblUser

Field name Field type Display As

UserId int UserId

UserName nvarchar(50) UserName

UserPassword nvarchar(50) UserPassword

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Where 

Code Sample

SELECT UserId, UserName, UserPassword


Page | 26 FROM tblUser
WHERE UserId = 1

nAML Illustration

SELECT

Table: tblUser

Field name Field type Display As

UserId int UserId

UserName nvarchar(50) UserName

UserPassword nvarchar(50) UserPassword

WHERE

UserId = 1

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Insert 

Code Sample

INSERT INTO tblUser(UserId, UserName, UserPassword)


Page | 27 VALUES (1, 'test1', 'passw@rd')

nAML Illustration

INSERT

Table: tblUser

Field name Field type Value

UserId int 1

UserName nvarchar(50) test1

UserPassword nvarchar(50) passw@rd

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Update 

Code Sample

UPDATE tblUser
Page | 28 SET
UserName = 'test00',
UserPassword = 'passw@@rd'
WHERE UserId = 1

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Delete 

Code Sample

DELETE tblUser
Page | 29 WHERE UserId = 1

nAML Illustration

DELETE

Table: tblUser

Field name Field type Primary Key

UserId int Yes

UserName nvarchar(50) No

UserPassword nvarchar(50) No

WHERE

UserId = 1

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Inner Join 

Code Sample

SELECT tblUser.UserId, tblUser.UserName, tblUserLog.DateLogged


Page | 30 FROM tblUser INNER JOIN
tblUserLog ON tblUser.UserId = tblUserLog.UserId

nAML Illustration

SELECT

Table: tblUser Table: tblUserLog

Field name Display As Field name Display As

UserId UserId LogId

UserName UserName INNER JOIN UserId

UserPassword Comment

DateLogged DateLogged

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Left Outer Join 

Code Sample

SELECT tblUser.UserId, tblUser.UserName, tblUserLog.DateLogged


Page | 31 FROM tblUser LEFT OUTER JOIN
tblUserLog ON tblUser.UserId = tblUserLog.UserId

nAML Illustration

SELECT

Table: tblUser Table: tblUserLog

Field name Display As Field name Display As

UserId UserId LogId

UserName UserName LEFT OUTER JOIN UserId

UserPassword Comment

DateLogged DateLogged

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Union 

Code Sample

SELECT UserId, UserName, UserPassword


Page | 32 FROM tblUser
UNION
SELECT UserId, UserName, UserPassword
FROM tblUserArchive

nAML Illustration

SELECT

Table: tblUser

Field name UserId UserName UserPassword

Field Type int nvarchar(50) nvarchar(50)

Display As UserId UserName UserPassword

UNION

Table: tblUserArchive

Field name UserId UserName UserPassword

Field Type int nvarchar(50) nvarchar(50)

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Insert­Select 

Code Sample

INSERT INTO tblUser(


Page | 33 UserId, UserName, UserPassword
)
SELECT UserId, UserName, UserPassword
FROM tblUserArchive

nAML Illustration

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

SQL Where­Select 

Code Sample

SELECT UserId, UserName, UserPassword


Page | 34 FROM tblUser
WHERE UserId IN
(
SELECT UserId
FROM tblUserLog
)

nAML Illustration

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Tools and Tutorial 
You can start implementing nAML just using a pen and a piece of paper. However if we had any
software level tool support to dram nAML diagram, it would really cool. Well, MS Visio is an excellent
modeling tool and has wonderful support for “Customized Stencil” to implement custom shapes. To
facilitate nAML modeling, custom stencil is available. Just download the latest “nAML Stencil”, install it
Page | 35 with your Visio and start drawing nAML diagrams. Here is a walkthrough regarding how to install and
implement nAML stencils.

1. Create a new drawing in Visio 2003 (or later)

2. Go to File -> Shapes -> Open Stencil…

3. Browse nAML Stencil (nAML.vss), where you downloaded and extracted nAML stencil.

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Page | 36

4. nAML Stencil will be visible in “Shape Explorer.

5. Drag and drop any nAML component

6. Edit and connect nAML components to establish application modeling.

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Page | 37

   

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 

Appendix: Common Attributes 
Attributes are one of the powerful features of nAML. Here are few simple samples which you can
utilize while modeling your .NET application.

Element Parent nAML Type Attribute Name Attribute Value


Element
Page | 38
ASP.NET Page None Element Class Name Text Value
Class Instance Name Text Value
Aspx Page Name Text Value
Executes on Web Server,
Browser
Network Location Text Value
Disk Location Text Value
ASP.NET Button ASP.NET Element Class Name Text Value
Page
Instance Name Text Value
Property: Text Text Value
.NET Class None Element Parent Class Text Value
Class Name Text Value
Class Category Abstract Class,
Basic Class
Instance Name Text Value
Language C#,
VB.NET
Disk Location Text Value
.NET Method .NET Class Operation Method Name Text Value
Method Category Instance Method,
Static Method
Method Visibility Public,
Private,
Protected,
Internal
.NET Method .NET Method Element Parameter Type Name Text Value
Parameter
Parameter Instance Name Text Value
Parameter Value Text Value
.NET Method .NET Method Element Return Type Name Text Value
Return Value
Return Value Instance Text Value
Name

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 
Return Value Text Value
If Statement .NET Method Operation Condition Text Value
Assignment .NET Method Operation Assignment Text Value
Statement
Loop Statement .NET Method Operation Count/Condition Text Value
Page | 39
.NET Property .NET Class Operation Property Name Text Value
Property Type Text Value
Property Value Text Value
Database None Element Content Category Sql Server 2000,
Sql Server 2005,
Office Access 2007
Database Name Text Value
Network Location Text Value
Disk Location Text Value
Database Table Database Element Field Name Text Value
Show As Text Value
Type Number;
Text;
True/False;
Binary;
GUID;
Date/Time
Stored Database Operation Procedure Name Text Value
Procedure
Stored Stored Element Parameter Type Number;
Procedure Procedure
Text;
Parameter
True/False;
Binary;
GUID;
Date/Time
Parameter Instance Name Text Value
Parameter Value Text Value
Select SQL Stored Operation Table Name Text Value
Procedure
Table Select SQL Element Field Name Text Value
Field Type Text Value
Show As Text Value
Update SQL Stored Operation Table Name Text Value

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 
   .NET Application Modeling Language V1.0 (Beta 1) Specification and Examples 
 
Procedure
Field Name Text Value
Field Type Text Value
Value Text Value

Page | 40 Insert SQL Stored Operation Table Name Text Value


Procedure
Field Name Text Value
Field Type Text Value
Value Text Value
Delete SQL Stored Operation Table Name Text Value
Procedure
Where Stored Operation Condition Text Value
Statement Procedure

Copyright 2008 © Mohammad Ashraful Alam, Microsoft MVP 

Das könnte Ihnen auch gefallen