Saturday 26 May 2012

.NET Debugging in Visual Studio 2010

Everyone involved with .NET programming know how to use the basics of the powerful debugger available in Visual Studio 2010. It is pretty easy to use and very useful. However, very few people explore all the tools available and sometimes you can be very surprised to discover something truly amazing that you was completely unaware of. This post want introduce some of that things.

Show Next Statement

When you are in the middle of a debugging session it can be easy to get lost. You can switch back to the next statement using the "Show Next Statement" option.


Debugging .NET Code

You can debug the .NET Framework code. You need to check "Enable .NET Framework source stepping" and "Enable source server support." in the debugging options and you need to add a specific symbol file server.



Pinning the Data Tips
Everyone know that when you hold the mouse on a variable during the debugging you can explore the value inside a data tip. However, nobody knows (me included), that this data tip can be pinned. This is very useful in some circumstances!



Immediate Windows and Intellisense

A another important thing to consider is the immediate windows. You can run complex code and update variables during the debugging session and there is full
Intellisense support (using CTRL + SPACE to activate it).


Intellitrace

Intellitrace is a very sophisticated debugging tool that allow you to go backward in time and reduce the number of times you have to restart your application for the debugging. This is a feature only available in Visual Studio 2010 Ultimate.


More information on MSDN.

Thread Support

In Visual Studio 2010 there is a specific windows (Thread Windows) that allow you to explore the various threads that are running at the specific point of time and easily switch between them. You can even give a name to a thread in order to be able to later recognise it.




It is also possible to see in which line of code each thread is, using the "Show Thread in Source" option.



Debugger Canvas

This is available only for Visual Studio 2010 Ultimate. I never tried it but I have to say that it looks awesome. It allows to see the context of the debugging session in a much broader way as a set of interconnected code balls. This tools is extremely powerful and support also 
multi-threading applications where each thread is represented by balls of the same colour. Finally, it is possible to export the diagram as an XPS file.




Tuesday 22 May 2012

DotNetToscana and Gadgeteer

Saturday 12 May there was a DotNetToscana event about Gadgeteer and .NET Micro Framework. I was in Italy that time and I participated. I really have to say that the event was great. Gadgeteer represent a very interesting platform for creating prototypes and simply for having fun. The various modules are still quite expensive but in the future I could maybe try to do something in this area especially to put under test some of my new knowledge about artificial intelligence.

The most interesting part of the day was when we moved a rover.

We saved that moment in a video :)


Here few pictures:





For other pictures, videos, material about the event you can visit the following page:
http://www.dotnettoscana.org/net-micro-framework-presenta-gadgeteer.aspx

A big thanks to Marco Minerva and Marco Dal Pino for preparing and running this brilliant event.


Friday 4 May 2012

Book - Code Simplicity

This book is awesome !!!

It is very short (less than 100 pages) but contains a lot of truth about software design in a very condensed way. At the end, it defines a list of laws and rules that any good software engineer or architect need to know and follow constantly to create really valuable and long-term software.



It starts with a comparison that I believe is very effective to underline how complex the software is:
Windows 2000 was 30 million lines of code, something like writing a book of 200 million of words - over five times the size of the Encyclopedia Britannica.
Everyone can easy agree with the following sentence:
The average computer program is so complex that no person could comprehend how all the code works in its entirely
The author believe that the software design can be defined as a science. Even if you don't agree with him, the list of laws and rules presented in the books are still extremely helpful and important.

The most important foundational law of the book is:
The purpose of software is to help people
This fundamental law bring towards the three goals of a science of software:
  • To allow us to write software that is as helpful as possible
  • To allow our software to continue to be as helpful as possible
  • To design systems that can be created and maintained as easily as possible by their programmers, so that they can be - and continue to be - as helpful as possible
The book then define the Equation of Software Design that the author call the Primary Law of Software Design:

D = V / E

This equation should help to prioritise the work and can be summarised in this way:
The desirability of any change (D) is directly proportional to the value of the change (V) and inversely proportional to the effort involved in making the change (E)
that can be reduced to:
It is more important to reduce the effort of maintenance than it is to reduce the effort of implementation.
So, nearly all decisions in software design reduce entirely to measuring the future value of a change versus its effort of maintenance. The quality level of your design should be proportional to the length of future time in which your system will continue to help people.

Then, the book introduce the Law of change:
The longer your program exists, the more probable it is that any piece of it will have to change
explaining the typical mistakes that software designers make when attempting to cope with this law:
  • writing code that isn't needed
  • not making the code easy to change
  • being too generic (Over-engineering)
Perfect easy of maintenance is impossible but it should be the ultimate goal.

Finally, the Law of Testing:
The degree to which you know how your software behaves is the degree to which you have accurately tested it
I strongly recommend this book. I definitely insert it in my restricted list of favourites books.