Jan 25 2008
VS 2008 & C# 3.0
One thing in C# 3.0 I don’t really like are extension methods. At the beginning – when I first read about this new feature I thought that it was cool. The idea that you may add new behaviour to the types you did not create (and have no sources to rebuild them) seems very attractive, but… after thinking about it a bit longer I have changed my opinion. Now I think that this feature brings more harm than good. It makes something looks different than it really is. It may confuse person that is going through the source code and is looking for bugs in it (because why should you not trust methods of String type or any onther type that comes in BCL? Yes, I know that you may right-click and choose ‘Go to definition’ – but my point is that this feature makes your code harder to read). I think static helpers are much better solution (and you do have to write static helpers to use extension methods…).
For me personally, the two new features I may call timesavers (and yes, they are great ;) are:
- automatic properties – I think most of us feel that C# lack this feature. It is not so uncommon to create a simple property (such that you do not have to add more code into getter or setter than automatic property does. And as for me – I think that you should consider creating special Get/Set methods instead of property when Get/Set operation is complicated. This way someone using your class is aware that this particular operation could take a long time and it should not be called too frequently).
- anonymous types – great idea connected to LINQ. Sometimes it is very convenient to be able to create a variable of an unknown type (and don’t be forced to create implentation for the new type first).
Partial methods. Some people seem to think of them as a way not to emit method metadata (if method is not implemented). I just wonder why there is so much misunderstanding about the concept of partial methods. The funny thing is that a lot of people think of them rather as a Conditional attribute. I think this is the most powerfull of new features added in C# 3.0. Thanks to it you may be able to provide some mechanism very similar to “aspect programming” (just provide some methods like before and after and if it will be needed the user may implement them and be sure that actions take place in right time.
One thing I really do NOT like in VS2008 is that there is still no support for XNA Game Studio 2.0. I do not like it that I just have to switch to older version of VS, I lack some new features in VS 2008. I hope that XNA team will soon release new version of XNA GSE that will work fine with Orcas.
And the last thing about new Visual Studio is… I have already encountered a bug connected to WPF designer. It just stopped working some day. It was impossible to add new control, change properties of controls… I started to search for some solution to this problem, and I found out that I should delete all TBD files (everything is described in details on MSDN forum). Kinda strange for me… but it is not the first time that deleting helps VS to recover from some strange behaviour. I remember that I had a problem with VS 2005 after installing some add-ons (from Microsoft). My keyboard just stopped working in VS (well… it did not stop working at all, but some keys just seemed not to work – enter, space – those are two I remember). Resetting all options to default did not help. After googling for quite a while I just found suggestion to delete VS settings… yup, it worked ;) Now I think, that I will try to delete VS settings at the very beginning if something brokes again…









May 8th, 2009 at 8:01 am
hh… good one :)
May 14th, 2009 at 10:29 pm
thanks :)