Nathan J Pledger

Program.X musings from the Isle of Man concerning ASP.NET, in particular accessibility, web standards and neat ideas.

July 2006 - Posts

C# 3.0 : Lax Programming

Reading www.thedailywtf.com today and I happened across this article about C# 3.0:

http://blogs.tedneward.com/2005/09/22/Language+Innovation+C+30+Explained.aspx

I've already mentioned I am unhappy with the LINQ implementation, in that it softens the difference between your tiers, but I accept it is a useful addition and am looking forward to using it myself - particularly for quick binding of controls.

This article really unnerves me though, it introduces some concepts which I feel would introduce lack coding practices. I was to believe C# would be type-strong, and that little more strict than C++.

Implicitly typed variables

Variables that imply their type on compilation, eg:

var i = 5;
var s = "This is an implicitly typed local variable";
var a = new int[] { 1, 2, 3 };

What happened to the type-strong C# I grew fond of? This is a reversion to the practices of a Variant, and the hassle that comes with it.

Object Initialisers

Instead of coding all those constructors, often repeating the same constructor logic, or at least calling the this constructor to make the code a little less repetitive. If you had a property PropertyA defined, then you could instantiate a new object by calling the ocnstructor, eg.:

MyObject o=new MyObject{PropertyA="Hello"};

But what if there was a reason why those properties were managed by the constructor?

I can see me having problems maintaining any sense of best practice in coding standards in ou team when this is implemented.