Software Architecture – What is exactly Tuple in C# – Compare with classes, structures,Array,ArrayList,List

March 20, 2011

In previous post at Software Architecture – C# – 4.0 – New Feature – Tuple , I introduced Tuples. During a presentation Badar-one of my team mate asked me question that why we need a new type tuple-When there are already classes,structures,Array,ArrayList,List. So I posting my reply.

Actually Microsoft is growing C# as most prowerfull programming langauge, so they contionously extend the core language element. Tuple has been there in Pythone and F# previously, now with c# 4.0, it is also part of core c# syntyx.

Comparsion with Class/Structure:
So problem defination is that we want to group together related values/ types into one type.
First thing comes in mind to have Class and contain all elements to be grouped in side a class. Sounds good,but there are cases when there no objec t oriented concept related to grouping. Class comes with heavy concepts like Encapsulation,Pholymorphism,abstraction,inheritence,constructor and a lot more… So when grouping is required but there is no OO sense, then Tuples are best choice.
You may point out that Structures are also there. Again there have attached concepts like inheritence,constrcutor,methods,properties and lot more. So when just grouping is required but no Object oriented concepts, tuples are the best choices.

Comparsion with Array/ArrayList/List:
No..No you can’t compare Tuple with Array/ArrayList/List.Because of simple point that Tupe is treated as data type and Array/ArrayList/List are treated as data strcutures. Just visualise the basic course with “Data Structure” in BCS, you will know the differenc e. Array/Arraylist/List are affilated with general concepts of Data structure like sorting , searc hing and a lot more. For Tuple we don’t have any such concept. It is simple Grouping og related values/types.

Getting and Setting elements in tupes is totally different from other Data strcutures like Array,ArrayList/List.

Secondly, elements in array are not strongly types(Require a type casting),but elements of Tuples are strongly typed.


Software Architecture – IntelliTrace is a historic debugger

March 14, 2011

IntelliTrace is a historic debugger which acts like a Flight recorder or DVR Recorder.
It is only available in Visual studio 2010 ultimate.

According to MSDN:

Here are some examples of how IntelliTrace can save you time:

>>You set a breakpoint near the start of your application. After observing the state of your application at that point, you continue execution. Later, you decide you want to go back and look at the first breakpoint hit again. Without IntelliTrace, you would have to restart your application. By using IntelliTrace, you can find the breakpoint event in the IntelliTrace window, and then click the breakpoint to view the state of your application at the time that the breakpoint was hit. State information includes variables that you have examined previously through DataTips or variable windows.

>>You discover that your application has corrupted a data file or a registry entry, but you do not know where the file or registry corruption has occurred. Without IntelliTrace, you would have to look through your code to find all possible file or registry accesses, place breakpoints on those accesses, then rerun your application to find where the problem occurs. By using IntelliTrace, you can see all registry- or file-access events that have been collected and the state of your application at the time each event occurred.

>>An exception occurs. Without IntelliTrace, you receive an exception message that states the nature of the exception but you have limited information on events that led up to the exception. You can examine the call stack to see the chain of calls that led up to the exception but you cannot examine the sequence of events that occurred during those calls. By using IntelliTrace, you can examine events that occurred at multiple times prior to the exception.

Best video to get explination about IntelliTrace is as:

Some others are as below:


Enjoy debugging.


Software Architecture-Exception-Snapin project-Porting from .Net 3.5 to .Net 4.0

March 13, 2011

Exception:

Could not load file or assembly ‘XXXXX, Version=5.5.3484.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Environment:
There is a snapin project in solution. After porting solution from visual studio 2008/.Net 3.5 to visual studio 2010, the above exception is appearing.

Solution:
Add an environmental variable named COMPLUS_Version with value v4.0.30319 where v4.0.30319 is your version of .Net framework
This change will solve the above problem.