My first real taste of C#
Well, I’ve dabbled with C# before, tweaking a RunUO instance, but this is the first time I’ve actually used the language in anger, writing something from scratch, so I figured I’d just jot down a few thoughts. The project… a PowerPoint add-in.
Why am I writing anything about a language that isn’t new? Well, being a die hard Delphi fan-chick I thought my first foray into the world of C#, .net and Visual Studio may provide some useful insight to any other Delphi developers looking to move to the dark side
So, the project… right now, I’m preparing a big presentation for work. It’s a training course, and as such I have some things I want to do… these aren’t mind blowingly clever things, but PowerPoint out of the box just can’t do them without some pretty intensive labour. For example… macros at design time… you can’t (or at least I couldn’t find any way of doing it) have macros assigned to shortcut keys that run in the editor… you can’t even access useful events like ‘PresentationOpened’ without resorting to an add-in.
With this information in hand, I figured that I’d implement all the funky features I want in my own custom add-in. If it pans out and I can make it work well (so far it’s going really well all things considered) then I may release it as a low-cost commercial product for other budding presenters.
But enough of that… lets get into my thoughts.
The environment… the first thing is the obvious difference in keystrokes. Somethings that in Delphi require a single keypress require key combinations in Visual Studio. I know that the more I use it, the more conversant I’ll become with the GUI, but for some reason many of the keypress don’t follow logically. Take the Step Into, Step Over and Run buttons… Delphi, it’s F7, F8 and F9 respectively. VS it’s F11, F10 and F5 respectively… hardly a logical progression. In Delphi, F12 toggles between the visual form and it’s code… in VS, it’s F7 for the code and Shift+F7 for the visual form.
My next gripe… double clicking a C# source file in the project explorer in VS opens the editor with some HTML in it??? WTF? Double click means open the file I’m clicking in practically every other context I can think of, so why in VS does it open something else? Even using the ‘Open’ option from the popup menu results in the same thing! I’ll say it again… WTF???
The editor in VS is OK, I find some of it’s auto-formatting stuff a bit annoying because it ends up with code which isn’t in my natural style, but at least the code ends up looking fairly standardised without too much effort from me. The visual form designer seems a bit clunky somehow… I can’t quite put my finger on it, but suffice to say, I don’t think it’s as nice to use as Delphi’s.
So, I’m not overly impressed by the environment.
The language… I’ve said this many times to colleagues… a good software engineer will be able to pickup a new language and be productive with it in a matter of hours. Now not wanting to blow my own trumpet, but all things considered (new environment, first real use of the language, first Office add-in and first Office ribbon customisation) I would say I’ve done pretty well. The guts of my add-in are now complete and I can interact with my presentation in (for the most part) the manner I wanted to. I have a few small gripes but these are of my own making and I plan to fully tackle them later, but for now… I can setup the data I need, I can store information in the presentation and retrieve it… and the whole thing has only taken me about 8 hours (including time design icons). Most of this has been engineering the ribbon customisation.. it’s so picky and the documentation sucks. The help is appalling… for some reason my local help is limited to the Windows Mobile SDK so I have to go hunting for information on-line… great when I’m at home, but shite if I’m sat in an airport terminal with no WiFi. I’d like to say that Delphi’s help is better… in some respects it is… it’s all there, locally, out of the box, but compared to the help that shipped with Delphi 5, both VS and the later versions of Delphi suck when it comes to the help they provide.
Setting up the project… this was a snap… simply create a new project using the Visual Studio Tools for Office and you get the option to create an add-in. Add ribbon customisation as a project component and you’re away… it really is that easy. I’ve dabbled a little bit with the Windows Mobile SDK in the past, and creating an app for my smartphone was just as easy, so big up to Microsoft on that. Whilst I could probably do the same with Delphi, I just know that it would require lots of fiddling and faffing to get anywhere close to a working add-in. Who wants that hassle? Besides, I’m a firm believer in picking the right tool for the job and in this case VS and C# is it.
I was going to say, the one thing I really like about the VS editor is it’s region capabilities… but I just fired up Delphi 2009 and that supports regions… Cool
So what have I concluded from this first foray into the world of C# and VS… well… I’ve said for quite a while that what makes .net development difficult is the size of the libraries, and I stand by that. Some of it gets in the way, like nearly everything being an object… I know in Delphi there are lots of objects, but C# just seems to be a little too OO in places. Overall though, I’m pleased with the progress I’ve made and I’d be pretty happy to get into some more in-depth development with the tool set, but there are somethings I just don’t like. Classes for example… no definitions… just bang it all in the body of the class… it makes finding stuff a pain in the ass as you can’t just skim a header and jump to the implementation of the method like you can in Delphi, regions help but it’s still a nightmare. The use of ‘this’… in some places it seems to be required, but in other it doesn’t… this could just be my n00biness showing through, but when I’m in a class in Delphi I hardly ever use ‘self’.
Overall though, I’m pretty pleased and I hope to have my add-in finished with just a couple more hours of work, and well… I have now at least used it in anger… the question is, is that worthy of a place on my CV?


