Monday 16 November 2009

NFR

The past few weeks have been quite busy making it difficult to rant... I am going to break this hiatus with a lighter post...

Recently i stumbled across a post by Marcus on the various Non Functional requirements to be captured in any project. Marcus captures all the aspects of non-functional requirements and its a great ready reckoner for anyone interested in them...

Saturday 12 September 2009

Modeling using Visual Studio 2010

Its been a while since i wanted to write about the modeling capability which comes along with Visual Studio 2010.. Yeah!!! you heard it right modeling capability in Visual Studio!!!

Last couple of editions of Visual Studio had fragments of tools like Application Designer, System Designer, Logical Datacenter Designer, and Class Designer. However, apart from class designer i don’t think anyone has used the other designers in live projects. The lack of adoption was primarily because the designers not based on UML standards (Class designer was to some extent). The lack of standards meant one has to rely on Visio or tools like Rational Rose to do the designs… Apart from the lack of standards, couple of things which i didn’t like are lack of support for capturing requirements and interconnectivity between the designers (of course application designer and system designer was interconnected but that didn’t pass on to class designer). So the story of complete Life cycle management using Visual Studio Team Suite/Visual Studio Team foundation was incomplete in my mind.

With Visual Studio Team Suite 2010, Microsoft is trying to change that with new modeling tools and support for UML. It has done away with the designers mentioned above except Class designer. Lets look at what the new tools and what they offer…

To begin with we have the new type of project template in Visual Studio name “Modeling Project”

image

This project is used to create different UML diagrams like use case, activity diagram, component diagram, sequence diagram and logical class diagram.

Use Case Diagram

Use cases provides a way to document the functional requirements of the system. With the use of use case diagram, now users can document functional requirements and also create work items out of it. The use case diagram provides most of the features. One thing which i was searching and didn’t find is constraints, which helps to put restrictions on which the use case will operate. See below a sample use case diagram created using Visual Studio. One cool thing which i liked is, for each of the use cases you can associate work items and track it. This gives a very good traceability.

image

Activity Diagram

Activity diagram is used to model state machines like workflows. The activity diagram in Visual Studio covers most of the stuff available in UML 2. Below sample shows the activity diagram created using Visual Studio. As with use cases, you can create work items for each action item. One thing which i was looking in activity diagram which was missing is swim lanes which helps in separating the actions performed by various users/departments.

image

Component Diagram

Component diagram helps to describe the components which make the application. The below picture shows the component diagram created using Visual Studio 2010. Again as in the previous diagrams, you can create work items based on the components. One cool thing with component diagrams is that you can create sequence diagram from this. Selecting “Create Lifeline” from the context menu of the action item creates the sequence diagram. In component diagram something which was missing was the assembly connector which is used to bridge the required and provided interface.

image

Sequence Diagram

Sequence diagram helps to describe the interaction between the various components. Visual Studio 2010 provides some re-engineering capability and creates sequence diagrams from a method, this helps to understand the code better. However there seems to be a bug and it works only for the Generation scope of Current Project.

image

The below picture shows the sequence diagram created using Visual studio.

image

Logical Class Diagram

Logical class diagram let the user to model the classes, interfaces and enumerations used in the particular application. Logical class diagram has almost all the features available in UML 2 class diagram. The one key thing which i noticed was the attribute types.. Only 4 types are listed… not sure what happened to the other types… One important thing which is missing is the ability to re-engineer the existing code and create class diagram from the same.

image

The list of UML diagrams provided is a good improvement from earlier versions of Visual Studio, however there are still quite a lot of diagrams to be covered like Deployment diagrams, State machine diagrams etc and not to forget the full UML 2 support in all the diagrams.

Apart from the UML diagrams, there is one other diagram which can be created using the Modeling Project. This diagram is called layer diagram. This is the diagram which will be used by the Architects to define the architecture of the application. The cool thing about this diagram is that it comes with in-built types of architecture like 3-Tier, 4-Tier and MVC. The architect can use this as boiler plate and then start customizing the diagram. The below diagram shows the 4-tier layer diagram created using the template provided.

image

One cool thing about the layer diagram is it provides the ability to validate whether the components developed confirms to the architecture. The validation can be done from the designer, command line and also the build process.

Dependency Graph

Using Visual Studio 2010 its very easy to create the dependency graph which will come handy during re-engineering of existing code. The dependency graph can be created based on assembly, namespace or class.

image

The above picture shows an example of dependency graph which is generated using Visual Studio 2010. With the help of the dependency graph it is very easy to find out the assembly/namespace/class which are dependent on a particular assembly/namespace/class.

Visual studio allows you to view the dependency information as a matrix as well as shown below.

image

One bad thing about dependency graph (at least the beta 1) is it just hogs memory… It eats so much memory that not even 3 GB of RAM is enough of it… :-(. Hopefully this will be rectified in the RTM.

Conclusion

With Visual Studio 2010, UML is back as the modeling language within Microsoft’s IDE. Though it doesn’t have the full breadth of UML 2 capabilities still its a good start by having some of the important diagrams in place. Once the full support of UML 2 is added into the IDE it will be a force to reckon with thus giving a complete Life Cycle management.

Saturday 29 August 2009

.NET 4.0 CLR Enhancements

I was looking at .NET 4.0 and was thinking if there are any enhancements to the CLR at least this time? (Remember the last enhancement of the CLR was about 4 years back with the release of .NET 2.0. Both .NET 3.0 & 3.5 used the CLR which comes with .NET 2.0). As it turns out, the CLR part of .NET 4.0 has quite a lot of enhancements. So without further ado, lets look at the enhancements…

  • In-process side By Side CLR

I guess this is one of biggest enhancement in the CLR. In the earlier versions, the host process can only load one version of the CLR. CLR used something known as the unification policy to figure out the single version of the CLR to be loaded in the process. This can cause compatibility issues to say the least. The biggest challenge with this limitation is for the add-in developers as they can’t be sure which version of .NET framework their code will be run. The code has to be checked for various compatibility issues if the authors need it to be perfect.

With .NET 4.0, it will be possible to run multiple CLR versions side by side on the same process. So it is possible to have a host process which has three add-ins developed in .NET 1.1, .NET 2.0 and .NET 4.0. This should be music to the ears of add-in developers.

  • GC enhancement

Pre .NET 4.0, when Garbage collection happens you would notice the application to pause when the Gen 2 size is quite large. Also, the GC is a concurrent GC i.e. it will not be able to do Gen 2 collection when Gen 0/Gen 1 collection is in progress and vice versa.

With .NET 4.0, collection algorithm has undergone quite a bit of change which means the collection will be faster than before. However, the application will still pause when collection happens. .NET 4.0 provides notification feature which can be used to get notified before collection happens.

.NET 4.0 also provides a new type of collection named Background collection. With background collection, Gen 0/Gen 1 collection can happen while doing Gen 2 and vice versa. This will help in reducing the latency during application execution.

  • Support for Dynamic & Functional Languages

With .NET 4.0, there will be support for dynamic and functional languages like IronPython, IronRuby, F#, etc. With the support for these languages, CLR will have capabilities like Tuples, Biginteger and Tail Recursion which were added for these languages. All the languages supported by the .NET framework will be able to benefit from these additions for example, biginteger can be used in C#.

  • Corrupted State Exceptions

There are certain exceptions which cannot be caught by normal catch statements like Invalid Memory, AccessViolation, etc. It is possible to catch these exceptions with .NET 4.0 with the help of Corrupted state exceptions. Corrupted state exception(CSE) can be handled by the program by adding the attribute [HandleProcessCorruptedStateExceptions] which signals to the CLR that the program wants to handled CSE.

  • Code Contracts

Code contracts introduced in .NET 4.0 is a best way to tell the compiler about what we know about our program in terms of parameters and their permissible values for a particular function. Code contracts helps you to provide the behavior of the function in terms of pre-conditions and post-conditions. These conditions helps to perform both runtime and static analysis of the code behavior.

  • Native/Managed Interop

With .NET 4.0, there wont be any PIA’s which makes it easier for the managed application to call COM libraries. The TLBIMP tool will be available as a shared source through codeplex thus making it easy to modify the code based on our requirements to generate the interop assembly.

P/Invoke has become much simpler with .NET 4.0 with the use of wrapper tool. With the wrapper tool it will be easy to create P/Invoke wrappers for windows API’s.

  • Threading for multi core

Parallel extensions in .NET 4.0 help to write programs which target the multi-core environment. Parallel extensions make use of the Thread pool part of the CLR for allocation of threads. Thread pool has been enhanced to provide better support for multi-core scenarios.

  • Profiling

Its not longer required that you have Visual Studio installed on your production servers to do profiling of the application. With .NET 4.0, new API’s have been added which enables to attach/detach performance and memory profilers.

  • Debugging

With .NET 4.0 it is now possible to do dump debugging using the interface ICorDebug.

Phew!!! that’s quite a lot of enhancements to the CLR. Of the whole lot, my favorites are the In-process side by side CLR, GC enhancements and Code contracts.

Reference: CLR Futures by Joshua Goodman

Technorati Tags: ,