Thursday, February 28, 2008

Project closure...End of March

It’s another month to go !. Ye, I am talking about my project; I was working on the security, task scheduling and logging component of an ETL application. It’s been 1+ years since I started on this project, it’s based on a J2ee backend, and .Net 1.1 front end.

At first I did not like the project as it was being developed in .Net 1.1, but as it went on I learnt many things especially on designing, globalization techniques and most off all managing customer communication.

I was also exposed to working with several teams (as we were handling the common service), and this proved to be very challenging and useful when it came to different viewpoint and opinions.

I did not learn any new technologies in this project but I did learn most of the things that I might be able to carry forward in other projects in the future.

Yesterday, the clients officially announced that project is getting closed down, and probably it would stay until the end of March.

Well, I know what I am going to really miss when this is all over, coming late to work…

Monday, February 25, 2008

ASP.NET MVC Framework

ASP.NET MVC Framework is another extension that has been added to .net 3.5, this framework allows developers to create ASP.NET projects using the MVC pattern (of course as the name suggests!).I took a look at it and it seems pretty easy to use. You can learn more about it here.

Just to give an idea about how easy controllers can be implemented, take a look at the code below...
public class CustomerController : Controller
public void ListCustomers()

The CustomerController class extends the base class System.Web.MVC.Controller, this base class does most of the job.
For an example, when a request comes in the form, the framwork automatically calls the above method , cool ne?

Friday, February 22, 2008

Extension methods and Lambda expressions

Maybe it’s a bit late for me to post about .Net 3.5 + VS 2008, but that’s what I am exactly doing these days.
My first interest in the language was on Lambda expressions and extension methods and then LINQ.
I have learnt quite some stuff about LINQ, meaning the basic, but still did not have a time to try out LINQ to SQL, maybe I will, in the coming week.

Just to give you an idea about Lambda expressions, this is an evolution of anonymous methods in .Net 2.0 and this comes in handy when using LINQ. You can read more about Lambda function here.
Extension methods are really cool stuff, this allow you to add new methods to the public contract of an existing CLR type, without having to sub-class it or recompile the original type. So for an example you can write a extension method like Print() and add it to the string class and you can use is it like this.

String str = “Say Hello World”;
You can read more about Extension methods here.

Another thing that I tried out was the object Initialize feature, this allows you to set field values when creating objects.Note that the actual field initialization occurs after calling the default ctor. For an example I can do this ...
Student stu = new Student{FirstName = "Nairooz", LastName = "NIlafdeen"};
you can read more about this here

Wednesday, February 20, 2008


LINQ, Language Integrated Query is a new feature in .Net 3.5. Tradiationally, a programmer
needs to different query language to query different datasources, for example, data sources like
Sql databases, XML and in-memory objects. This meant the programmer needed to learn
different query languages for each and every technology. There was another problem as well, queries were
written in string form and cannot be validated at complie time.
LINQ tries to address these problems, by giving the programmer a singel query language
for any data source for which providers are available.
The cool thing about LINQ is, it is in-built into the language such as C# and VB.Net and Visual studio provides Intellsense support.
This is a sample query of what LINQ can do:

public void Linq11() {
List products = GetProductList();//Get an ArrayList of products, not from the database

var productInfos =
from p in products
select new {p.ProductName, p.Category, Price = p.UnitPrice};

Console.WriteLine("Product Info:");
foreach (var productInfo in productInfos)
Console.WriteLine("{0} is in the category {1} and costs {2} per unit.", productInfo.ProductName, productInfo.Category, productInfo.Price);

Thursday, February 14, 2008

Being part of an interview

I always wanted to be part of an interview, and today I got the chance. I was given a chance to accompany one of the interviewers at Virtusa. I got a chance to throw some question as well, not very hard once but you know…basically I did not have much questions.

Anyway, kind of liking this, maybe I should do this often.


Wednesday, February 13, 2008

Memory leaks in managed code

This was something we ran into in our application used custom GUI components, and well those were rough days…


You sometimes hear that a managed language like C# or Java does away with memory leaks, and frees the programmer from having to think about freeing objects from memory. Well this is not especially true for GUI code.

The main reason for this is the use of the Observer pattern. While a good thing in it self, the observer pattern leads to the “Lapsed Listener” anti-pattern. This is when an object A subscribed to an event of object B which is a long living object (for an example a child form subscribing to event in the parent MDI form) goes out of play without unsubscribing to the event on object B (the child form closes but without unsubscribing from the event on the MDI parent).

This would result in object A never being garbage collected until object B is out of business, what’s worse, if object A reference other objects C and D , this will also not get garbage collected as well.


This would lead into couple of problems…

1)       Memory usage of the application grows with time.

2)       If the leaked objects includes controls that hold GDI objects (Windows, Pens etc..), eventually you may run out of these.

3)       The unwanted and presumed –dead objects are still capable of receiving events, this may cause crashes.


The general solution is to make sure you unsubscribe from parent events in your dispose method (in .Net).

We had to use a tool to monitor memory consumption and then fix them most probably by disposing events and so…The tools we used to monitor memory were Sci-tech Memory profiler and ANTs profiler both of which are not free, but the best tools in the market for this job..

Tuesday, February 12, 2008

SharePoint training

I was having my usual time at home today when I remembered “my god I have a training to catch”…

I had to race into office and finally made it at around 10 AM. The training was on Microsoft SharePoint server, the trainer was Joy Pradeep one of the MVP of Sri Lanka.

The training was good but the first few hours were mostly concentrated on the administration side of SharePoint, I did not get a chance to look into the development section of as I had to attend to another one of those “urgent” tasks.

I remember the same thing happening when I was in a BizTalk training, the first day was great (with some network games on the training lab), and as it turned out be the 2nd day I had to miss it.

Monday, February 11, 2008


Cool tool for .Net, ILMerge. This allows you to merge two assemblies into one target assembly. One most obvious use for this would be when you have two project one written in C# and one in VB.Net, using ILMerge you can combine these assemblies to distribute to your customer as if you have developed it in one project !!!.

Friday, February 8, 2008

Debugging WCF services hosted in IIS 6.0

I have been doing some sample projects in WCF (hosted in IIS 6.0), and today I was trying to debug the service like I have done with web services and but with no luck, the break point does not get hit at all !!!, After some goggling found out that direct debugging of projects in the same solution is not possible with WCF.

The work around is to run your client and then attach to the external process aspnet_wp.exe and your break points will hit.

Debugging of WCF services in the same solution will be possible in VS 2008.

Back for good!!!

Ok guys I am back in the mood to blog, I do remember I said this before but this time it’s for the best...I have been having a hard time at work and did not fins sufficient time to send a post.

I have made up mind to take some time of my work to post a message or two at least every week !!!