MVC: Class Diagram – Building a Class

Leveraging a GUI tool to quickly construct a class.

In this article I will demonstrate Visual Studio’s Class Diagram tool which allows developers to quickly construct a C# class with much less errors.

First, I’ll create a new model class to demonstrate this feature.

1-MVC-Class-Diagram---Building-a-Class

Next, I’ll invoke the tool.

2-MVC-Class-Diagram---Building-a-Class

Now I’m presented with a new class diagram with designer pane and property window.

3-MVC-Class-Diagram---Building-a-Class

I’ll right-click the Class object to leverage the context menu to create my FirstName property.

4-MVC-Class-Diagram---Building-a-Class

After naming my property I’ll change its datatype to string.

5-MVC-Class-Diagram---Building-a-Class

By double-clicking the Class object, I’m taken to my new class’s code.

6-MVC-Class-Diagram---Building-a-Class

Since this property need only support trivial get/set operations I prefer to use auto-implemented properties available since C# 3.0.

7-MVC-Class-Diagram---Building-a-Class

Now I’ll repeat the process to create a more robust Model.

8-MVC-Class-Diagram---Building-a-Class

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s