Some stuff about Web and .NET development
RSS icon Email icon Home icon
  • Visug summary : Modeling that works with code

    Posted on November 15th, 2009 Thibaut 1 comment

    Visug

    Last Visug edition, animated by Marcel De Vries from InfoSupport, concerned modeling with Visual Studio 2010. Note before we start that all of this is only available in the ultimate edition of VS 2010.

    Overview

    • Why we use models
    • Models first approach
    • Code first approach
    • Conclusion

    1. Why we use models

    • Diagrams for communication
    • Diagram = viewpoint on a model
    • Model use is challenging because :
      • Many interpretations of the same diagram
      • UML available but people uses a few diagrams only (ex : use cases)
    • Models become stale because :
      • Implementation will be different from the model
      • Maintaining diagrams takes time & effort
    • Ultimate goal : run a model (Oslo vision), from a metamodel store (data repository)

    When to create a model ?

    • It’s about communication, so create only models that serve a purpose
    • Create only models that differ from the normal case

    Two approaches

    • Models first
    • Code first

    2. Models first approach

    Scenario : you start a project and need to define the solution you’re going to build

    • Requirements analysts : use activity diagrams & use cases to outline functionality
    • Architects : build logial diagrams to outline required architecture to meet customer demand stated in the requirements
    • Testers : use the diagrams to do its test analysis based on the specified requirements
    • Developers can use the diagrams done previously to materialize the projects

    => Models are used to communicate throughout the team about what we’re going to do

    In Visual Studio 2010 Ultimate Edition :

    • New project type : modeling project
    • Support for UML 2.X diagrams
    • Other new types of diagrams : Layered diagrams & DGML diagrams

    Diagrams can be generated from code. The speaker uses it to generate sequence diagrams for code reviews. Note that those diagrams are plain XML files but it’s recommended to manipulate them via the API (cause in a next version, maybe Microsoft is going to change the format).

    3. Code first approach

    Scenario : maintenance of existing projects.

    • Developer can generate diagrams to gain insights on code dependencies
    • Architect can find architecture patterns
    • Architecture explorer helps discover and understand how a system works

    Layer diagram

    • Used by the architect to define the architecture
    • Classes and namespaces are mapped to layers in the diagram
    • Details the intended design
    • Diagrams are very interesting to verify the architecture and enfoce it.
    • In VS2010, there’s a tool to validate the architecture. Ex : you draw 3 boxes (UI, BLL and DAL), you link (arrow link) the UI to the BLL and the BLL to the DAL, you drag/drop your projects into the correct box. You then click “validate architecture” and you get a report about what’s violating the dependencies defined by the arrows.
    • You can also use these diagrams to validate things such as code coverage in percentage for a given layer.

    DGML

    • Directed Graph Markup Language
    • Nodes
    • Containers
    • Links
    • Styles

    You can also create you own diagrams (Progression API). You code in C# the way you want to generate the diagram. Styles can also be defined. Ex : speaker coded a diagram with nodes that must appear green or red (styles) following the code coverage percentage. Can also be used to annotate existing diagrams.

    4. Conclusion

    • Models & diagrams primarily for communication
    • VS2010 supports both approaches : code 1st and models 1st
    • New innovations in models that work with code (DGML & layered diagrams)

    Also note that ScottGu is going to visit Visug in december so stay tuned ;)

    Share/Save/Bookmark