Jan 25 2008

VS 2008 & C# 3.0

Category: ProgrammingMaciek Talaska @ 1:28 pm
I have been using VS 2008 & .NET Framework for my personal needs for quite a while and I would like to share some of my thoughts about the new technology. As for changes in C# 3.0 – you can find complete list of changes in .NET Framework (and C#) on MSDN , all those new things in C# 3.0 are also explained in details on Daniel Moth’s Blog (under “Orcas” OR “Visual Studio 2008″ labels and there is a great post that describes most of the new features in VS2008 and .NET 3.5). There is even an event about .NET 3.5 you may be interested to watch.

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…

Tags: , ,


Jan 24 2008

RSS readers with synchronization

Category: Programming, free thoughtsMaciek Talaska @ 9:31 pm
Since the moment I discovered rss feeds I can hardly imagine living without it. But… there is one problem with rss for me. Readers. I have tested various readers and I could not find one that would suit all my needs:
  • possibility to use the reader on many machines (I am thinking about some kind of synchronization)
  • I am keen of desktop programs – so it would be nice to have a desktop application (that could stay in system tray while working) and to be notified when new things appears
  • it would be great if there would be possibility to use web based client – in case when installing desktop software is not possible (for example: reading feeds using some pda’s…)

For a long time I have been thinking that the best solution is Google’s web based rss reader. It has almost everything I want. There is also a lightweight version made especially for older pda’s and phones (Google Reader Mini) and a bit more sophisticated wrapper on Google Reader for mobile devices that can handle not only static html (ReaderMini – currently still in beta).
Google Reader and all similar solutions have one big advantage – you do not have to think about synchronizing state of your feeds. You just log on – on any machine you are currently working on – and that’s it. You got everything you need. But not everyone is a keen of ’software inside a browser’. Web based rss reader does not alert you about updated feeds – but there are some plugins for Firefox (and for others web browser too, I think) that will pop information about latest changes in your feeds. The biggest problem with Google Reader for me is that when I want to use Google’s search engine – I am logged. I don’t like it. I feel like Google knows much more about me that I would like them to.

Thats why I have started to write my own small application based on Google Reader that would stay in system tray and alert me about new feeds and allow me to read the content not having to bother about synchronization issues. I have found Nial Kennedy’s article about Google Reader API, I have also find some gossips about Google’s will to release Google Reader API to public in near future. Unfortunatelly it seems that Google no longer wants to make Google Reader API available to wide range of programmers all over the world. Later – after digging up for a while – I have found a small utility by BrianDotty called Google Reader Notifier - that allows you to have information about new feeds presented in the well known ‘tray ballon’ way (yup, I did use Reflector The Great ;> to see how to log into Google Reader ;) Another thing I have found was complete (I think) API for Google Reader written in C#. It is a pitty that there are no links for the applications that are using this API (GReader Desktop, GReader Mobile – both mentioned on the main page of the ‘Google Reader .NET API’).
After few days going through the code it stroke me that it is totally pointless to create another feature-rich rss reader. The best thing would be just to embedd a WebBrowser control in an application that could reside in system tray and provide some information about the feeds (how many feeds are unread and so on). So I just cut out all those things that were ‘extra’ and build a simple application with .NET WebBrowser control. It worked great but… it seems to consume a lot of memory. After using it for a while I have realized that it allocated about 60-70MB of RAM! And even the special trick with minimize-restore did not help much. I was wondering if it was a problem with WebBrowser control or with Google Reader. Hard to say at the moment but I plan to investigate this issue further on. The simpliest solution (embedded WebBrowser control) has one big advantage: you may go to your Google Calendar / GMail / Google Notebook with only a few clicks (and yes, you do not have this feeling that Google knows everything about you – whenever you use their search engine ;)

A few days ago I have found information about free NewsGator desktop application for reading rss feeds that has ability to synchronize information about your feed’s state between various machines. I tried it… and I think it is great. The desktop application is well known FeedDeamon that is now given by NewsGator for free. It almost perfect. You are able to use desktop or web based version of the reader – so all the time you know what have you read and what is still marked as to-read or important. There is one thing As for me FeedDemon lacks easy retrieval of older content for selected feed. Using Google Reader I got used to being able to see what were the previous posts / entries in selected feed. You just scroll down – and thats it – Google Reader automatically gets them for you (if there are any). I must say that FeedDemon is really easy to use and does not need a lot of memory – after having it run for more than 20 hours it did not consume more than 20MB.

I you are just like me – and synchronization and availability of desktop reader are the most important for you – you should give NewsGator a try – but I will give my application another chance and see what is the real problem with such a hughe memory consumption.

Tags: ,