Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Best use of .NET 3.0 extension methods

with 2 comments

If you want to know what is .NET 3.0 extension methods visit ScottGu‘s post will help. Anyway it is not the main topic i want to discuss here; what I want you to help me is to build a business rule for the following use case.

extending seat

Toyota HQ, Change Request Accepted.

Cambodia is one of the country imported alot of second hand cars; and the best use of those cars are in Taxi business. Due to the quality of the car made from good material the users “Car owner” had come up with an idea of extending the car seat by converting the Car’s boot into reservation seats.

After review change requests Toyota HQ decided to build a custom Car for Cambodia only. A friend of your who is an engineering at Toyota his job now is to build this car with low cost. Lucky he had previously attended a few TechEd conferences so familiar with .NET 3.0 extension methods which allow him to attach new functionality to the existing car architecture :) and so he jump right into code:

public static void Load(this Car car, Guess g){
  if (car.RunIn == “Cambodia”
    && car.TotalGuessInside >= 8
    && car.Boot.IsStillFree
    && car.AverageSpeedKMph =< 75 ){
    if ( g.IsSingle ){
      if ( g.Partner.HasThirdPartyRelationship || g.Partner.Age >= 30 )
         throw new InvalidToHellPermissionException(
             @"Your partner is still young if you really want to do
               that let get their written permission");
    throw new InternationalTrafficLawException(”OMG!”);

And he asked me to review his code since I’m a Cambodian resident I should be able to tell him what are the criteria he missing; but I am a bit out of date with current taxi business how about you my dearest friends any idea for inclusion?


Written by Chorn Sokun

September 5, 2008 at 11:05 pm

Posted in Joke

Tagged with

2 Responses

Subscribe to comments with RSS.

  1. Hi Sokun,

    I just want to clarify if you intended to mean Extension Method in .NET 3.5 or C# 3.0.

    I’ve found your blog and website, especially, very interesting.

    Keep up good work.

    chau seung

    chau seung

    September 14, 2008 at 11:56 pm

  2. I am pretty sure it was available in .NET 3.0; csharp 3.0 specification and want to know what .NET 3.5 are all about here. It is M$ marketing strategy to promote 3.5 instead of 3.0 I believe.


    September 15, 2008 at 8:13 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: