Class diagram: a easy way to understand code

Scope

This article has the goal to show how to create a class diagram and how we can use it to understand code.

Introduction

According to MSDN, a “Class diagrams help you understand the class structure of projects others have written (or that you wrote a long time ago). You can use them to customize, share and present project information with others.”

In this article we will use the sample Field Engineer from MSDN Samples which is an Azure Mobile Service sample, but where is not required to know about Azure Mobile Service and we will not talk about it. We only focus in the model classes as a sample.

Description

After open the Field Engineer Sample in Visual Studio, we will find a folder with the name “Model”, here are an image with it

model folderIn this case we do not have so many classes, that can be great because can be easy to understand the model. Maybe a lot of developers will start open all files to see the code, but why not create a class diagram?

Let’s create first a class diagram for see an overview about the model.

Creating a class diagram

Selecting the Model folder and opening the context menu, click in “Add” and then “Class Diagram” as following
add class diagram

then define the name of the class diagram as following

class diagram name
clicking in “OK” the diagram file will be added to the project and will be opened, as following
class diagram in projectnow we can select all files in model folder and drag and drop it to the class designer area and the result will be
drag and drop result

and now we should move each shape and should expand each one for see details.

Expanding classes

For expand click in the arrow in top, as following
expand shape

and the result will be
shape expanded

The class details

If we open the context menu under the shape we can select the “Class Details”
select class details

the result will be something like it
class details

With this user interface is possible to see more details about the class and is possible to create/edit/delete/hide each property, method, event… without coding.

Understanding different icons

After expand all shapes we will find that some shapes show the Fields, Properties, and Methods (and can show events, nested classes…).

Let’s see the case of the MobileServiceContext

MobileServiceContext shape

Looking to the image we can conclude

  • The connectionStringName is private and is a const field;
  • All properties are public;
  • The method MobileServiceContext that is the constructor is public and the method OnModelCreating in private;

How is possible to conclude it?

Each icon means something, for example the symbol * in each item means it is private. The best way to understand the differences between each icon is to create a sample with each possible case.

Let’s see a fake class created for this purpose

class details
When we select the shape and open the context menu we have options that allow to show/hide different details.

Let’s see the case for show the base class.

Show Base Class

base class

After it and after expand the shape for MyBaseClass we will have something like it

diagram

In this moment, there are one point that can be important to defined, to show the diagram what is the most important information that should show in the diagram?

It depend what each developer likes or wants to see, but in general we can defined as a pattern, we should show only public properties, methods and events and hide all others (in some cases can be useful to show all defined as internal or protected).

Hide compartment

Selecting the shape and the item we want to hide is possible using the context menu do this, as following

hide itemsThe option “Show all members” will revert it, but in some cases is better to use the Class Details for revert it, because we can have others items hidden that we want to keep hidden.

Each shape that hidden some item will show an icon that means it, here are an example

hide symbol

Apply associations

Returning to the Field Engineer Sample and choosing the class JobHistory, Job and Customer we will find that each one has a relationship with each others, let’s highlight it using a  red and orange rectangle, as following

related classes

Let’s see how we can show the association for properties and for collection.

Show as Association

For properties which the data type is another class we can select the property in shape and in context menu should select the option “Show as Association” as following

show as associationShow as a Collection Association
and for properties that are collections/lists we can choose the option “Show as Collection Association” as following

show as collection association

and the result will be something like

associations

The number of arrows will define it is a property or a collections, but using a good name can be enough to see the differences.

Show as property

By selecting in the arrow is possible to revert it, using the option “Show as property”.

Show as property

The final class diagram

After define all arrows for all association and organizing the shapes we will have something as following

final diagram

For this diagram, we can understand that the model has five classes and the MobileServiceContext is defined by these classes. Is clear the relationship between the classes which allow to conclude (for example)

  •  A job know its job histories and each job history refers to a job;
  • A job knows which customer is associated and a customer can have more than one job;

A similar conclusion can be done for Equipment and Equipment Specifications.

Note: is possible to create arrows for the MobileServiceContext’s properties but it only will do some noise and is not important in this case to see these associations.

Each developer should customize the class diagram and there are no fixed rules for it. With this kind of diagram is very simple to understand the model and in some cases found mistakes like wrong names, wrong relationships or even missed features.

Conclusion

In conclusion, we can conclude that the class diagram is a very useful for understand the code made by us or by others, the relationship between the classes and an easy way to find mistakes. In some cases, with class diagram is possible to have a big picture about the application without see one line of code.

 

See also

Survey about Android development in Visual Studio

The Visual Studio team would like to thank you for helping us understand more about Android development and debugging.   We want to hear about the tools and technologies you are using (as either a hobbyist or fulltime) for Android development.  We appreciate your time helping us shed some light on this area.

The information you provide is entirely voluntary.  By filling out and returning this survey, you agree that we can use, disclose, reproduce, or otherwise distribute your feedback at the aggregated level. Your personal information will remain confidential. Please check http://privacy.microsoft.com/en-us/default.aspx for Microsoft Privacy Statements.

 

If you have any questions about participating, please feel free to contact vsdr@microsoft.com.

 continue…

Survey on API Consumption and Tooling

APIs lie at the heart of our cloud-first, mobile-first strategy. In order to provide you with the best-in class tooling for consuming our wide variety of APIs – VS Online, Office 365, Dynamics, Azure, Xbox, Bing, to name just a few – we would like to learn more about your experience. Which APIs provided a particularly pleasant experience to develop against? Which tools do you use on a regular basis? Where do you see room for improvement? No matter whether you just started using your first API or are an experienced developer, whether you are using Microsoft or other services, we are looking for your feedback.

survey

This survey can take as little as 5 minutes to complete and it is completely anonymous. Your feedback will help shaping a set of new developer experiences, inside and outside of Visual Studio. If you are willing to participate in further user studies or discuss your experience with us in person, be sure to check the opt-in box and provide your email address, we will then follow-up with you on feedback sessions. Please also pass the survey on to other developer who you think may want to provide input.

 

 

Survey for Web App developers or Cordova developers

Developer Experiences Building Hybrid and/or Web Apps 

The Visual Studio team is looking for developers building hybrid apps using Apache Cordova™  and developers building web apps to provide feedback on their experiences. Your input will provide direct feedback to support changes in future versions of Visual Studio.

 

This survey can take as little as 5-10 minutes to complete. We are also looking for people to join 30 minute feedback sessions to talk about their experiences in a phone call. If you are interested in joining a feedback session please let us know in the survey. If you are selected to participate in a feedback session, a coordinator will contact you with details regarding scheduling and gratuity. When completing this survey you may also opt in to our survey sweepstakes* for a chance to win a $100 or $50 gift card.

 

The information you provide is entirely voluntary. If you do not wish to provide us with any information, please disregard this survey. By filling out and returning this survey, you agree that we can use, disclose, reproduce, or otherwise distribute your feedback at the aggregated level. Your personal information will remain confidential. Please check http://privacy.microsoft.com/en-us/default.aspx for Microsoft Privacy Statements.

*See details on the next page on how to qualify

 

Request for IOS and Android devs: Packaging and Publishing Experiences

The Visual Studio team is looking for Android and iOS developers who can provide feedback on app packaging and publishing experiences. This survey can take as little as 5 minutes to complete and will provide direct feedback to support changes in future versions of Visual Studio.

 

The information you provide is entirely voluntary. If you do not wish to provide us with any information, please disregard this survey. By filling out and returning this survey, you agree that we can use, disclose, reproduce, or otherwise distribute your feedback at the aggregated level. Your personal information will remain confidential. Please check http://privacy.microsoft.com/en-us/default.aspx for Microsoft Privacy Statements.

 

Use this url: https://illumeweb.smdisp.net/collector/Survey.ashx?Name=PackagePublish

[PT] Cross Platform Development w/ Xamarin: workshop (Lisbon)

Cross Platform Development w/ Xamarin: workshop
Event ID: 1032589721

Microsoft Lisbon Experience

Rua do Fogo de Santelmo, Lote 2.07.02
Lisboa Lisboa 1990 – 110
Portugal
Language(s): English.
Product(s): Microsoft Visual Studio.
Audience(s): Academic, Architect, Developer Generalist, IT Decision Maker, IT Implem_App/LOB Spec, IT Manager, NonProfessional Developer, Pro Dev/Programmer, Project Manager, Tester and Training – Partners.

O mundo de dispositivos que hoje temos ao dispor apresenta desafios cada vez maiores aos criadores de Aplicações da nova geração: como otimizar esforços para fazer o target destes dispositivos sem ter de recorrer a equipas cada vez maiores com competências específicas para cada plataforma ou ter de assegurar o suporte a esse conjunto disperso de aplicações?

 

Michael Köster junta-se a nós neste final de tarde para mostrar como é possível, utilizando o Xamarin e o novo Visual Studio, desenvolver Aplicações para Windows, iOS e Android de forma a minimizar o seu esforço de desenvolvimento e suporte.

Contamos consigo!
A Equipa Visual Studio da Microsoft Portugal

Nota: este evento é gratuito e será conduzido em Inglês

Conheça o Xamarin for Visual Studio: http://xamarin.com/visual-studio
Conheça o novo Visual Studio: http://www.visualstudio.com/

 

AGENDA:    

 

18h00

Receção e Credenciação

18h30


Cross-Platform Development Overview

A high-level overview of challenges, approaches and tools for building applications that target multiple form factors and technologies, covering both backend and frontend scenarios.

 

Michael Köster, Microsoft

19h30

Coffee-break & Networking

20h00


Build native cross-platform applications with Xamarin

Xamarin is the new standard for cross-platform mobile development. No other toolset enables developers to reach all major device platforms with 100% fully native apps from a single code base. With Xamarin, developers do mobile development in C# and can share on average 75% of code across platforms. Leverage existing skills, teams, tools and code to deliver great apps with broad reach quickly!


Michael Köster, Microsoft

21h00

Encerramento


Source:
https://msevents.microsoft.com/CUI/EventDetail.aspx?culture=en-US&EventID=1032589721

[Visual Studio] Help make Edit and Continue better!

Do you get tired of seeing this box (I know I do)?

Tell us about it!

The Visual Studio team would like your anonymous feedback on improving Edit and Continue (E&C) when developing .NET applications. This survey can take as little as 3 minutes to complete (I’ve saved you some time already by copying all the words on that page to this page so you don’t have to read it twice) and will guide ongoing support and making it work in more places. If you consider yourself a regular E&C user or would like to see improvements that let you use it more often – we need to hear from you!

Please take a few minutes to complete the survey @ http://aka.ms/encsurvey and if it’s not too much trouble tell all of your developer pals about it. Blog, wall, and tweet the link to anyone who’ll listen!

The information you provide is entirely voluntary. If you do not wish to provide us with any information, please disregard this survey. By filling out and returning this survey, you agree that we can use, disclose, reproduce, or otherwise distribute your feedback at the aggregated level. Your personal information will remain confidential. Please check http://privacy.microsoft.com/en-us/default.aspx for Microsoft Privacy Statements.

 

 

My Visual Studio extentions

Here are my extensions in Visual Studio 2012

And for Visual Studio 2013

and i use Reshaper!

Visual Studio Evolution

Visual Studio Evolution – Microsoft Lisbon Experience

Começa: segunda-feira, 24 de Março de 2014 09:00
Termina: segunda-feira, 24 de Março de 2014 13:00

Rua do Fogo de Santelmo, Lote 2.07.02

1990 – 110 Lisboa Portugal
Idioma(s): Português.
Produto(s): Microsoft Visual Studio e Windows Azure.
Destinatário(s): Arquitecto, BDM com influências tecnológicas, Formação – Parceiros, Gestor de TI, Implem_Apl. TI/Espec. LOB, Programador Generalista, Programador Pro e Verificadores.

Ao longo dos últimos anos temos trabalhado a família de soluções Visual Studio para que tenha nas suas mãos as ferramentas mais avançadas do planeta que lhe permitem, e à sua equipa, criar aplicações extraordinárias que todos os dias fazem a diferença nos seus utilizadores.
Agora, com o Visual Studio Online, demos um passo mais além trazendo o poder e flexibilidade da Cloud para o seu próprio ambiente de desenvolvimento, para que se possa focar naquilo que mais interessa: a sua equipa e as suas aplicações.

E com este evento, o primeiro onde vamos abordar este tema, queremos ajudá-lo a estar na linha da frente mostrando-lhe em primeira mão os detalhes técnicos desta nova era do Visual Studio – uma agenda que irá incluir um overview destas novidades mas igualmente uma abordagem em profundidade a tópicos como Testes (usando o VS Online e o Windows Azure) ou as novas soluções de Application Insights incluídas na plataforma.

Tudo, para que conheça o que pode fazer com estas novas ferramentas que pode já hoje começar a experimentar.

Contamos consigo!
A Equipa Visual Studio da Microsoft Portugal

AGENDA:

9h00 – Registo & Credenciação

09h30 – 10h30 – Visual Studio Online – Tiago Pascoal

10h30 – 11h00 – Coffee Break

11h00-11h45 – Testes com Visual Studio Online e Azure – Luis Calado

11h50-12h50 –  Application Insights – José António Silva

12h50 – Encerramento

 

Mais informações aqui.