Happy New Year

The worst part about new years is that you need to remember to write the new year in all dates you enter. Last time my credit card payment bounced because I entered 2005 on the cheque instead of 2006 and I had to pay late payment charges Ok, now since I’m over my crib session…

1

Names of Indian Cities

The biggest issue with the names of Indian cities is that they change :). I know of some other countries where it changes as well. Of the 4 largest cities in India, 3 have changed names in the recent past. Calcutta became Kolkata (2001), Madras became Chennai (1996), Bombay became Mumbai (1995). The most recent being the change…

4

Conditional methods and their Parameter evaluation

In .NET the System.Diagnostics.ConditionalAttribute can be used for conditional compilation. A method can be marked with this attribute as followsusing System.Diagnostics; static class Logger { [Conditional(“TRACE”)] static public void Info(string message) { Console.WriteLine(message); } } This means that the Logger.Trace is compiled into IL only when the TRACE sumbol is defined either in the command…

4

Creating Immutable types

Someone asked on a C# DL “How do I create an immutable type“ The answer was obviously by creating a type in which you don’t allow writeable fields or properties or have methods that change the state of the type. However, the questions started revolving around how System.String have methods to update the string but…

3

Is object oriented programming good?

When we use a tool for a long time we get used to it and think in its terms rather than using it to help materialize our thoughts. Mostly this is not a good idea. We were taught OOP in college and kind of told that even though functional programming sounds cool its only for funky stuff…

5

switches and jump tables

In my last post I had discussed about how only constants can be used with C# switches. From the post’s comments and later discussing with other folks I learnt something that came to me as a surprise. A lot of people working on managed code consider switch-case to be a stylistic variant of if-else, and…

2

Why can we only use constants in a switch-case statement?

Why can we only use constants in a switch-case statement? The following code fails to compile with the error “A constant value is needed” for someStr as it is not a constant string. static void func(string str) { switch(str) { case “Zaphod”: Console.WriteLine(“The king”); break; case someStr: Console.WriteLine(“The coder”); break; default: Console.WriteLine(“None”); break; } }…

15

Test-driven development

A lot have already been said about Test Driven Development (TDD) by a lot of people, but I’d still like to add my 0.02paisa. We have an internal requirement of checking in UnitTests along with the product code and the code coverage for the unit tests needs to be high. Most of our developers have…

2

Conditional Text

We have moved to a new Satellite TV provider some time back. It is time to pay the quarterly bill, so I dug up their manual to look for online payment options. Sure enough there was a section on “Internet payments”. I opened the section and it had one line. “For Internet payment options click here“!!…

0

Change the world or go home

Saw this via Steve Clayton’s blog. This is going to be my new wallpaper…

1