Search

Friday, November 30, 2007

Ravenous Bugblatter beast on Indian roads

From the HitchHiker's Guide to the Galaxy.

"The Ravenous Bugblatter Beast of Traal is a creature that hails from the planet of Traal, and will eat anything. If you are to encounter one, the Guide tells you that it's impossible to slay, so you should wrap a towel around your head. This creature is so mind-bogglingly stupid that it assumes that if you can't see it, then it can't see you."

I felt like one while on a road-trip to Visakhapatnam and surely you'll feel like one on Indian roads. We were going at high speed and suddenly we see someone crossing the highway. We honked hard and the person simply looked down. So the idea is that, if he can't see you, then you don't exist. Or maybe they were using the SEP field technology.

In the following video watch the first person crossing the road and next a cyclist goes in the wrong direction as we wiz past at 120kmph (75 miles/hour).

Newbie Question: How do I figure out the inheritance chain of a type

Redmond_2005_0417_010447

I got this question from someone just starting out on the .NET platform. He is used to hit F12 (go to definition) on types and then figure out the inheritance chain. However, he couldn't do that say on a number (int) or array.

The solution is to write a simple recursive routine as follows

static void Dump(Type t)
{
if (t != null)
{
Dump(t.BaseType);
Console.WriteLine(t.ToString());
}
}

The routine can be called as follows

Dump(typeof(int));
Dump("abc".GetType());
Dump(1.GetType());
Dump(typeof(EventAttributes));
No marks for guessing the output though :)

Wednesday, November 28, 2007

Woohoo - Rosario November CTP is out...

2006_0311_123604

...and I can finally talk about what I'm working on for the last so many months.

First things first, for more information on Microsoft Visual Studio Team System code name "Rosario" November CTP release head on to Jeff Beehler's blog

A small bullet in the list of features is Manual Test execution. What it means is that you can now record you manual tests and play them back. Yes, it means you have a UI record and playback feature in the Manual Test Runner!! It's not a full fledged UI automation solution for now. It is mainly targeted to speed up manual testing so that the manual tester can zip past the part which she is not interested in testing. E.g. the manual tester can record the login, purchase pages so that she can play them to directly land in the final checkout page and do manual actions/validations on it.

The solution works for web-UI (IE pages) and also has very limited support for Win32 applications.

I work as a part of the team that develops the record and playback (RnP) framework. It's been an excruciating working on a great technology but not being able to publicly talk about it. Thankfully that time has ended :)

How do you name your computer

2006_1101_200024

Windows gives examples of "Kitchen Computer" or "Mary's Computer" for setting the name of a computer (Computer Name tab in System Properties). But I'm sure that most people don't name their computers that way and show off a bit of creativity in it.

Previously I used to use names from Asterix like GetAFix for my main dev box. Now I exclusively use names from Hitchhiker's Guide to the Galaxy. Some of the machines I use are named as below

  1. traal: My test box
  2. Krikkit: My dev box
  3. Vogon: A old vintage machine I have at work which I use to test some perf scenarios (Vista on 512mb RAM :^) )
  4. Hooloovoo : My personal laptop
  5. Bugblatter: Another laptop

What name do you use?

Tuesday, November 20, 2007

True object oriented language

 

DSCF2530

Today I was spreading the goodness of Ruby and why I love it so much (and you can expect multiple posts on it). SmallTalk programmers can sneer at me, but hey I wasn't even born when SmallTalk came into being and hence I can be pardoned for pretending that Ruby invented this :)

Languages like Ruby are "truly" object oriented. So even a number like 2 is an instance of the FixNum class. So the following is valid Ruby code which returns the absolute value of the number.

-12345.abs

Taking this to an extreme is the iteration syntax. In C# to write something in a loop "n" time I'd be needed to get into for/foreach syntax, however in Ruby I can do the following

5.times { puts "Hello"}

Which prints Hello 5 times.


However, I actually lied about having to use for/foreach statement in C#. With the new extension-method/lambda goodness we can very well achieve something close in C#.


For that first we create the following extension method

public static class Extensions
{
public static void times(this int n, Action a)
{
for (int i = 0; i < n; i++)
{
a();
}
}
}

Then we can call "times" on an int as easily (well almost as I still need some lambda ugliness).

5.times(() => Console.WriteLine("Hello"));
// Or
6.times(delegate { Console.WriteLine("Hello"); });

All programming languages evolve towards Lisp

 

2007_01_28 120

In an internal DL people were debating what all should be included in the next version of C#. One of the things I suggested turned into an interesting thread.

Abhinaba: Add if as expression (like in Ruby) so that I can do the following

var ageGroup = if age < 2
                   "Infant"
               else if age < 19
                   "Teen";

SomeOne: Can't we do

var ageGroup = ((age < 2) ? "Infant" : ((age < 19) ? "Teen" : String.Empty));

Abhinaba: We can but put 4 more cases and it’ll start looking like Lisp :) with all the parenthesis.


SomeTwo: All programming languages evolve towards Lisp.


Yeah, right!!!

Monday, November 19, 2007

Lack of Aspect Oriented Programming support in .NET

I was preparing for a presentation on Aspect Oriented Programming and I started re-looking for the solutions in .NET.

I'm personally not interested about any of the dynamic methodologies, be it dynamic weaving or any other form of dynamic proxying. To me CLR is static-typed and I'd want any solution to be the same (on DLR I'd definitely accept a dynamic solution). Predictability, performance, debugability are  major concerns that are not well addressed in dynamic methodologies. Some of the Dynamic approaches also have special requirements like they can only support virtual methods as join-points.

To me the perfect AOP solution on .NET would either be an IL weaver which ships as a post-compilation tool or an extension language. AspectDNG and EOS are good example for the two approaches respectively.

Wikipedia had a bunch of links and I tried couple of them. It seemed like most of the tools uses dynamic approaches and had the same issues mentioned above. From the static tools I tried AspectDNG's IL weaver. Even though the weaving was good it didn't update the pdb files resulting in very poor (or no) debugging experience. I tried EOS and liked it a lot. However, the project seemed to have died with no updates for a long time.

I think something serious needs to happen in this space. Either Microsoft or some other large body (serious open source project ?) needs to pick AOP up to make it successful in .NET. To me the tool of choice would be extension to the C# language in the same lines as EOS (or AspectJ).

There seems to be already some work going on like the Policy Injection Application Block which works over .NET remoting.

Saturday, November 17, 2007

The WOW factor in software

 

I care a lot about the nice nifty features that takes a software from being just a good software to a great software. It makes me feel that the developer really cared. I know how features are cut and these making it to the product indicate a mature, well thought-out execution.

Joel in his How to demo software writes

"bump into all the nice little “fit and finish” features of your product. Oh look, that column is halfway off screen. No problem. I’ll just drag it over. (“Wha!” the audience gasps, “you dragged a column in HTML?”) Oh, look, this feature is supposed to be done by next Tuesday. I’ll type “next tuesday” in the due date box. (“OMG!” they squeal. You typed “next tuesday” and it was replaced with “11/20/2007”)."

I absolutely agree to this. I've seen Microsoft Office time and again do that. The first time I fired up a PowerPoint presentation on a dual screen I gave that same squeal "OMG! the slide show start on one and I get the presenter view on the other with full access to the notes!!!!". Even 3 days back I used the same mode for a presentation on Aspect Oriented Programming and felt happy about using the product.

However, there's the other category of software which doesn't work in first place and tries to be smart on top of it. There's nothing worse than this. You look at these in disgust and head over to the dumber but working competition.

Thursday, November 15, 2007

Don't forget to lock your Computer

So Amit pointed me to this post on Coding Horror (I didn't get time to read any of the feeds for the last 2 days!!). It's about colleagues playing pranks with folks who leave their computer un-locked. I myself have done couple of these stupid but amazingly successful ones like taking screen shot of the desktop and then making it the wallpaper. Then you hide all visible things on the desktop so that the user on retuning goes on clicking on them without any result.

However, these days at Microsoft the prank has changed. On returning you just get to see an email typed out, addressed to Bill Gates. I don't even want to get into the topic of what is typed. The effect is amazing and permanent. Win+L keys become etched in your reflexes.