Model Xtractor - Online Class Diagram Editor
Model Xtractor - Online Class Diagram Editor User Account   
    RSS Posts | Model Xtractor
  • Diagrams
  • Metadata
  • Blog
  • Support
  • Tutorial

Minimized Shapes

Leave a Comment » Mar 1, 2010
Bookmark and Share
Categories: Tutorial

A common practice in object-oriented programming is to use the dot notation recursively on existing objects: to extract another object from some member returned type, then call another method on this object and so on, until you get to the piece of information you really look for. The intermediate objects serve only as extractors for the next object. Model Xtractor adds a small but very powerful feature to a shape, in order to adjust and better represent object scenarios, directly from the class diagrams: the possibility to minimize it. Minimized shapes appear as small circles with just the icon inside. Only the inner/outer connectors and their items are visible. A particular application of minimized shapes is for arrays and collections, that represent intermediate container types and appear minimized by default. Other kinds of minimal shapes, that look like small circles, are annotations (i.e. minimized comment shapes), implementors (for implemented interfaces) and instantiators (for public instance constructors). Instantiators can be used as entry points, for instantiable types, along with static type members or global functions.

Object Shapes and Annotations

Model Xtractor is focused primarily on class diagrams, but it can also represent dependency diagrams, and even object scenarios, with minimized metadata shapes. Consider the following portion of C# code, with types from System.IO namespace. We get the root directory of our C: drive, the owner of its ACL entries list, and first file as a FileSystemInfo object:

DriveInfo drive = new DriveInfo("C");
DirectoryInfo root = drive.RootDirectory;
DirectorySecurity access = root.GetAccessControl();
IdentityReference identity = access.GetOwner(typeof(SecurityIdentifier));
FileInfo[] files = root.GetFiles();
FileSystemInfo fsi = (FileSystemInfo) files[0];

A class diagrams with all types involved in this scenario would simply start by an expanded instantiator of the DriveInfo class. Navigate through RootDirectory to its DirectoryInfo. Expand the GetAccessControl item, and show all inherited members in the created DirectorySecurity shape, because GetOwner is among them. GetOwner returns an IdentityReference object. GetFiles of our root directory returns a dynamic array of FileInfo objects, from which we pick up the first element as a FileSystemInfo object, by looking at its base class:

Click for the published entry of the diagram
EditViewPrint

However, in this equivalent sequence of code we really don’t care about most intermediate objects (the directory, the ACL, the list of files) and focus only on the final result (an IdentitityReference object and a FileSystemInfo object):

DirectoryInfo root = new DriveInfo("C").RootDirectory;
IdentityReference identity = root.GetAccessControl().GetOwner(typeof(SecurityIdentifier));
FileSystemInfo fsi = (FileSystemInfo) root.GetFiles()[0];

Select all shapes of the diagram, except those two showing the result, and click on one of the small blue circles from the top-left corner of these shapes. All selected shapes became minimized, as small circles with only their icon inside (click again on their small blue circles from the top-left corner of the selection frames, to restore them to their previous expanded or collapsed status):

Click for the published entry of the diagram
EditViewPrint

Comment shapes can be also minimized, in which case they appear as small yellow circles and act like annotations. Their text is hidden and, if also made transparent, they will be totally invisible in the generated images of the diagram.

Implementors and Realizations

Implementors are <<implements>> dependency items, for an implemented interface of a class, dropped into the shape header when expanded (if dropped outside, they will expand into typical realizations, to the interface shapes):

Click for the published entry of the diagram
EditViewPrint

They look like small empty circles that can be moved around, move with the related shapes at the other end of the connectors and are automatically removed if the related shapes are deleted.

To expand an <<implements>> item into an implementor, drag and drop it on shape’s title area. All implemented interfaces of a type share the same connector and implementor, so if the small white circle is already there, for another interface previously expanded of the same shape, the item will be added below.

To collapse all implemented interfaces, select the small white circle and delete this implementor. To collapse only one implemented interface back into its shape, expand the shape, then drag the item and drop it in shape’s items area. If this was the only item in the connector, the implemented interface connector will automatically disappear. To collapse back a realization connector into an <<implements>> item, either select and delete the connector, or delete the interface-based shape.

Default position of an implementor is on the top-left corner of its shape, just above the shape. Click on the top-left small rectangular selector of the selection frame to reset this position.

Instantiators and other Entry Points

Instantiators are public instance constructors, expanded into connectors for instantiable types. They look like small black circles that can be moved around and move with the related shapes at the other end of the connectors. There can be always only one instantiator per type-based shape, shared by all the constructor items. Default position of an instantiator is on the left-top corner of its shape, on the left side of the shape. Click on the top-left small rectangular selector of the selection frame to reset this position.

Click for the published entry of the diagram
EditViewPrint

Instantiable types are an important concept for model navigation, because they can be used as entry points. When showing return types, instantiable and independent types appear in the Metadata tree with a –> suffix, and their shapes have round corners.

Other kinds of possible entry points, of type members that can be called directly, without an instance object previously created from their type, are global functions and static members. In Model Xtractor, global functions and constants are always translated into static members part of a surrogate type. When all members of a type are static, the type itself can be considered static. Static or global members appear in bold.

The diagram below shows different members that can be looked at as entry points in object scenarios. DriveInfo objects can be created by either calling the public instance constructor, or directly the static member DriveInfo.GetDrives. Enum type constants can be referred to directly, like in DriveType.CDRom, so they appear in bold. All members (fields and methods) of the Path class are static, and can be called directly, prefixed only by the class name. The class itself is static, and names here are displayed in bold. DriveInfo is an instantiable class and shows up with round corners, while Path doesn’t have a public instance constructor and its shape is rectangular:

Click for the published entry of the diagram
EditViewPrint

Leave a Comment

Accepts [code lang=".."] .. [/code], where lang is one of: csharp/vbnet/java/js/c/cpp/xml/sql/as3/php/ruby

E d i t   D i a g r a m s   O n l i n e !
Advertisement
Last Recommended Diagrams
  • WCF Binding
  • Membership (System.Web.Security Namespace)
  • System.ServiceModel.Syndication Namespace
  • System.Configuration: Sections and Groups
  • System.Configuration: Specific Sections
  • mx.utils
  • mx.preloaders
  • mx.controls.menuClasses
  • mx.controls.listClasses
  • mx.controls.dataGridClasses
Last Recommended Diagram
WCF Binding
WCF Binding
© 2010 Model-Xtractor.com - All Rights Reserved.
  • Terms of Use
  • Privacy Policy
  • News
  • About Us
  • Contact Us