Saturday, February 02, 2008

C# & Params Keyword

I ran into an interesting [at least to me :)] problem today.  How do I invoke all of the methods listed?

 

using System;

 

namespace ThinkFarAhead.Examples

{

    public class Params

    {

 

        public static void Main()

        {

            Max(1,2);

            //Max(1);  //Invokes #2?

            Max<int>(1,2);

            //Max<long>(1);  //Invokes #4?

        }

 

        //#1

        public static int Max(int first, params int [] values)

        {

            Console.WriteLine("[1] Param #2: {0}", values[0]);       

            return default(int);

        }

 

        //#2

        public static int Max(params int [] values)

        {

 

            Console.WriteLine("[2] Param #1: {0}", values[0]);

            return default(int);

        }

 

        //#3

        public static T Max<T>(T first, params T [] values)

        {

            Console.WriteLine("[3] Param #2: {0}", values[0]);       

            return default(T);

        }

 

        //#4

        public static T Max<T>(params T [] values)

        {

            Console.WriteLine("[4] Param #1: {0}", values[0]);       

            return default(T);

        }

 

 

    }

}

Sunday, December 23, 2007

My New Rig - Part I : Shopping

Well, in Delhi - where I live - we have this famous place called "Nehru Place" where we get all our components.    It's the pilgrimage we undertake when we have a requirement for a new PC. 

You need to understand that in India we do not have the likes of Best Buy or Fry's or any such specialized chain stores.  We have a Hong Kong style - China style? - bazaar, an array of stores so small that it cannot fit a compact car, teeming with people that tries to sell everything from software [pirated, of course] to sleaze to laptops to pre-assembled computers to full blown parallel processing marvels.

Yeah, I see you rolling your eyes.  Ok, I'm stretching it a bit but only the last bit ;).  And for those patriots, ok, we are the next US of A.  We do starting to have stores such as eZone that specialize in computer components.

The point is, when you ask for some component with a number such as D975XBX2, it's  most likely the shop in question would make a couple of phone calls to determine availability [to one of the shops in the same complex, of course] and say why don't I buy Asus P5KC.  It's the new in thing that the rest of the Delhi is buying [, you moron].

Another beauty is that you have to make your decision, in a jiffy.  You see, there will be people - at least a dozen - jostling with you, shouting at the shop keeper for a DDR 2 RAM or a Microsoft Ergo mouse.  The shopkeeper's attention span is usually less than a two seconds.  He'll be juggling two phones and a cellular phone simultaneously talking to his customers and vendors and showing off his parallel processing capabilities.

Bottom line:   I did dutifully accept the offer of taking an S975XBX2 instead of the asked for D95XBX2.

Here's my final component list:

  • A pirate's version of  Apple's cabinet with handles
    • I couldn't find the link where I saw the apple's design.  Will provide it later.
  • Intel Core 2 Quad Q6600
  • SG975XBX2
  • Transcend 4 GB DDR II RAM [800 MHz]
    • 4 single pieces.  Surprise, Surprise!  The guy didn't have a 2 GB pieces of DDR II
  • No Graphics Card
  • No Sound Card
    • All the newer boards support 7.1 Surround which would suffice my needs.
  • Ethernet Card
    • Most of the above motherboards have LAN built-in

I purchased them about 3 weeks ago.  At last, got sometime to blog [with my darling daughter throwing things at me in the background].

Sunday, December 09, 2007

Scalability in Physics vs. Scalability in Computer Science

In my experience, I've seen that most of the solutions are just a restatement of their scale.  That is, scale and the solution is so intricately intertwined, that the solution is not applicable to the same problem of a larger scale.  Unless, of course, the solution keeps scale in mind [a solution that can be scaled up, and more importantly scaled out].

I saw this [couple of months ago]:  A nuclear reactor built in the basement.

Hmm... I'm no physicist, but it seems scalability in software is a unique problem ;)

 

Technorati Tags:

Saturday, December 08, 2007

My Proposed New Rig: Core 2 Quad 6600

I think it's time for a new rig for me.  This would be my third - DIY - custom built system (See:   Jeff's DIY evangelism).   My current one is a Intel Pentium 2.4 GHz HT.  Here's the complete configuration:

  • Intel Pentium 2.4 GHz HT
  • Intel D865GBF Motherboard
  • Nvidia GeForce 6200
    • More recent addition, after I installed Vista Enterprise on an auxiliary drive
  • 1 GB DDR RAM [400 MHz]
  • HDD
    • 120 GB Seagate Barracuda SATA
    • 150 GB Samsung SATA
    • Elements 300 GB [External, USB]
  • No Sound Card
    • I find the integrated audio enough for my needs [4.1 Surround]
  • Ethernet Card
  • Samsung SyncMaster 206BW 20" LCD
  • Sony DVD +- RW Writer
  • Sony DVD ROM
  • Kensington Wireless Keyboard, Mouse Combo
    • I had a Microsoft Natural Ergonomic Keyboard 4000.  I also have an imp for a daughter - 2 and half a year old.  She had a field day drenching it with a mouthful of water. 
  • Creative Ultra Webcam
  • Intex Headphones

I run the following OSs:

  • Windows XP SP2 [primary]
  • Windows Vista Enterprise  [Auxiliary]

My proposed rig:

Proposed OS:

  • Windows Vista Enterprise 64 Bit

My new machine would probably inherit everything else starting from SyncMaster down from my old machine.  Also planning to keep my old one around.

I'll do a Jeff Atwood in the coming week assembling my new rig.

Update: VS.Net 2008 Team Suite RTM

I'm still seeing only VS.Net 2008 trial as you can see below:

vsnet2008teamsuite

 

A brainwave struck me about ten minutes ago.  OK!  Only trial is available for download but I read somewhere the trial or full version is determined by the product key - obviously!  This is what I'm seeing when I  went the Product Keys page:

 

vsnetkeys

 

It talks about VS.Net rather than VS.Net 2005 / VS.Net 2008.  I reckon this should work for VS.Net 2008 Team Suite RTM.  I've started downloading VS.Net 2008 RTM.  Oh, yeah, just 30 more hours to go :)

vsnet2008downloadfilemanager

Monday, November 26, 2007

VS.Net 2008 Team Suite RTM Download

I've a MSDN Universal Subscription as a result of my company's Volume Licensing Agreement with Microsoft (MVLS).  Since I've been hearing that VS.Net 2008 has finally gone RTM and is available for download to MSDN subscribers, I decided to expend some bandwidth on downloading it.

Unfortunately, I couldn't find it anywhere.    The first link loudly proclaims that VS.Net 2008 is available on MSDN subscriptions.  It also states  - the red underlined line - that "All English Visual Studio 2008 Editions will be available from 'Top Downloads' below". 

But the Top Subscriber Downloads has only the Trial version. 

vsnet2008download

The only VS.Net 2008 available seems to be the professional version.  Number of  people seem to have downloaded it successfully.  No such luck for me :( 

vsnet2008download2

I'm beginning to doubt if MSDN Universal Subscribers are eligible to receive VS.Net 2008 Team Suite or not.

Technorati Tags: , ,

Saturday, November 24, 2007

How to Generate RCW on the fly in your Nant Scripts

Have you ever tried to remember a research you've done couple of years ago and you're desperate to get your hands on the old code?  And the frustration of trying to remember what you did exactly, if you're unable to find or don't have access anymore to the source?

Well, I ran into one today:

Couple of years ago, I had to implement a build process for one of my projects.
One of the modules was a port from VB 6.0 (to VB.Net) and it was using MSXML2!

I wanted to generate the RCW on the fly for MSXML2.  Now, I want the solution to be generic enough to use on any project that uses interop.

I wrote a function:

<?xml version="1.0" encoding="utf-8"?>

<project>

<script language="C#" prefix="tlb">

    <imports>

        <import namespace="System" />

        <import namespace="System.Runtime.InteropServices" />

    </imports>

 

    <code>

    <![CDATA[

        <!-- Code Goes Here -->

 

    ]]>

 

    </code>

 

</script>

</project>

 

Here's the CDATA Section.  Given here to preserve formatting:

[DllImport("oleaut32.dll", PreserveSig=false)]

private static extern void QueryPathOfRegTypeLib(ref Guid guid, ushort majorVer, ushort minorVer, uint lcid, [MarshalAs(UnmanagedType.BStr)] out string path);

 

[Function("find-path")]

public string GetTypeLibPath(string guid, ushort major, ushort minor, uint lcid)

{

    Guid actualGuid = new Guid(guid);

    string tlbName = null;

 

    try

    {

        QueryPathOfRegTypeLib(ref actualGuid, major, minor, lcid, out tlbName);

    }

    catch (COMException e)

    {

        //Typelib wasn't found - tlbimp will barf

        //when the compile happens, but we won't worry about it.

        Console.WriteLine("[find-path] " + "ERROR!!! " + e.Message);

    }

 

    return tlbName.TrimEnd();

 

}


 

Now, wherever I wanted, I could use it thus:

<!-- Find out location of MSXML2 and create an interop assembly-->

<property name="com.typelib.fullpath"  value="${tlb::find-path('F5078F18-C551-11D3-89B9-0000F81FE221',3,0,0)}"/>

 

<!--

  Somehow the return value from the find-path function contains a character

  at the very end causing <tlbimp> to fail.  Removing the last character from

  the property as a workaround.     

-->

<tlbimp typelib="${string::substring(com.typelib.fullpath,0, string::get-length(com.typelib.fullpath)-1)}"

        output="${source.baseFolder}/Intouch8/bin/MSXML2.dll"

    />


The function I was trying to remember was the API call: QueryPathOfRegTypeLib.
Oooff... (sigh of relief).

Now that I've blogged it, I am sure I will find it next time :)

 

Technorati Tags: , ,

Monday, November 05, 2007

Core Values

I would like to work for a Software company that:

  • Values Technical excellence
  • Believes in being the best at what it does: Producing Quality Software
    • Good design produces a quality product that reduces rework later
    • Believes that software must be designed for change
  • Believes Software Development is fun!  And strives to keep it so.
  • Encourages a product mindset
    • A product mindset is one where even a small project of 3 months duration is developed as though it were a marketable product.
  • Believes fostering trust with the client
  • Emphasizes on automation to keep the process overhead to a minimum
  • Encourages people to learn constantly and rewards them for their knowledge.
  • Maintains a flat hierarchy
  • Emphasizes Agile project management practices

Somehow, I've come to think all other bullets can just be restated with a single sentence:  Agile must be the way of live in my dream company :)