C#: Provided by the management for your protection.
david.nikdel posted in general on February 10th, 2006
Honestly, I was not a fan of C# when it was first announced, but with Visual Studio 2005 and .NET 2.0, it has really come into its own. I recently got to take Windows Forms out for a spin while working on a project at work for collating the various log files that are generated on our kiosks. Each line in the log file has a time stamp, so we really needed nothing more than a GUI for reading in the logs, sorting them, and presenting the user with some search and save mechanisms. It’s a bit more complicated than that, but that’s the gist of it. Nothing hard, right? Maybe a day or two? I decided to use .NET 2.0 and Windows Forms and had the barebones features implemented within a few hours! That’s including the obligatory MSDN time since this was my first crack at Forms. It really is slick. Any property you can set on a control is accessible through the WYSIWYG editor, adding delegates is a snap (or a click as it were), and they’ve cleaned up a lot of the previous problem areas like adding menu and status bars and aligning things so they scale correctly when the window resizes. The best part was that everything I just described was set up even before I hit the code!
Once I got in there, it was easy to implement the base functionality while still having time to add nice-to-have features like a dynamic context menus, color coded rows for different log message types, and a status and progress bar. Even application preferences are niftily handled. You can define a set of properties to use as preferences in the WYSIWYG editor and a class is generated for the lot of them which takes care of persisting the values, calling delegates when they change and saving the new values should you decide to change them. All I had to do was implement a preferences dialog that presented the settings (within controls), allowed the user to change them, then saved them off when they clicked OK. There’s even the notion of application and user based preferences.
Combine this with the fact that every system function under the sun (as well as a host of utility classes) is exposed to you via an organized hierarchy and it certainly makes windows development seem like much less of a chore. They even fixed some of the big headaches from v1.0 like adding partial classes to rid the world of unsightly “don’t touch me” #regions. I can’t wait for .NET 2.0 for linux hehe. Now, I’m not convinced they have everything right when it comes to Web applications (for one, I really do not like the ViewState — more on this later) but for windows GUI development, this is the way to go, hands down. I will never use MFC again unless I have to, that’s for sure. It will be interesting to see how this all interacts with WinFX/Avalon and the new XAML GUI paradigm.
Leave a Response