Friday, 30 March 2012

Code snippets in Visual Studio

I must admit I was not a big user of snippets in programming. I used a few because they popped out in intellisense - for example while writing a for-each loop the snippet "foreach" comes up and we intuitively use it.

Never looked deeper to find other snippets. Today I realized I was at a big loss by not using them! Now I am never going to declare a property with all the key-strokes or writing if-else without using snippets. The no. of key strokes required are so less that it will improve developer's productivity by a good margin.

A few I like:
- mbox: If I use only this one it will save a lot of time for me.
- else: This one popped up in intelli sense but still didn't use it. 3 key strokes with snippet and 11 without
- prop: for automatically implemented properties
- ctor: for spitting out the constructor
- svm: for static void main

Other useful ones are 'surrounds with' snippets. Among these I like "try" which surrounds a code block with try-catch statement. What a time saver!

And another cool thing is we can add our snippets, it's just editing an XML file some where. I will see which ones are missing and add on my own. Should be fun.

(This reminds me there is so much still to learn and that even the smallest of things can be of BIG use)

Tuesday, 13 March 2012

Xsd2code

http://xsd2code.codeplex.com/

A tool which helps generate C# code from a XSD file. It can be very useful to generate classes which have a long list of properties - and you want to add WCF DataContract attributes, INotifyProperty code on these properties.

It also can be used when your application has lots of reference data. We can manually create XSD file with the reference data as enumeratio, then generate the class - and use this class in application. The class can be serialized and loaded back again if new items can be added by user.

There is also an option to auto-generate the classes if XSD file changes, I believe this requires installing a VS plug-in. The classes generated are partial classes, we can create another partial classes with same name if we want to add our own business rules.

#read: Code Generation in the .NET Framework Using XML Schema
http://msdn.microsoft.com/en-us/library/aa302301.aspx

Monday, 12 March 2012

Books (currently reading and to read)

Currently reading:
- Advanced MVVM
- LINQ in Action
- Pro LINQ
- WPF Unleashed

To read:
- Software Requirements:



- Pragmatic Programmer
http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X


- The Passionate Programmer: Creating a Remarkable Career in Software Development (Pragmatic Life)
http://www.amazon.com/The-Passionate-Programmer-Remarkable-Development/dp/1934356344/ref=pd_sim_b_6

- Code generation in .NET


Refactoring: Improving the Design of Existing Code






C# Reactive Extensions - Buffer and Window

I was going through Buffer and Window in RX, thought a few examples would help clear the differences. First create a buffer of even numbe...