Jesse Liberty, author of one of my favorite books (Clouds to Code) gives an overview of “My” in Visual Basic 2005


Blurb copied using the cool “Blog This” link on the ondotnet pages 🙂

Rapid Application Development with VB.NET 2.0 by Jesse Liberty — For a couple of years now, Jesse Liberty been touting the Microsoft endorsed-sentiment that it really doesn’t matter if you program in C# or in VB.NET, since both are just syntactic sugar layered on top of MSIL (Microsoft Intermediate Language, the true language of .NET). That appears to be changing a bit with Whidbey. Jesse Liberty investigates the new My object in VB.NET 2.0.

Comments (5)

  1. Tim P. says:

    Jesse ends the article with this:

    "VB 2 has taken a dramatic lead in Rapid Application Development with the My object. This raises the question of why this facility is not available in C#. Unless there is a clear performance penalty in using the My object (I’ve not tested that yet) there is no reason to turn our C# noses up at anything that makes programming easier; after all, the more that is provided by the framework, the more we can concentrate on designing and building the application."

    Yes, I agree that the My keyword does improve RAD, but does it really add anything new? It seems more like a bunch of scattered methods aliased in one place, and managed methods, too. My.Computer, for example, seems to just pull all the computer related fields from the Environment class. If it was a new set of managed features that encapsulated previously unmanaged functions in the Windows API, I would consider it to be more like a new feature. A C# programmer could encapsulate the functionality in a class and make their own "My" class which would provide equal RAD, plus the time it took to make it, but the developer would only have to make it once. Hats off to the VB.NET for this intuitive feature, but I don’t really think it gives VB.NET any bragging rights. I guess it’s kind of like the With statement in VB.NET, it’s an exclusive feature, but not one that all C# developers are jumping to have because it doesn’t add any new features, it’s just a time saver. For the record though, I don’t profess to know everything about the My keyword, so if I said something incorrect or sound like a baffling fool, please point it out.

    P.S. I’m not trying to start a language war, I just wanted to express my opinion. 🙂

  2. Tim P. says:

    P.P.S. I concur that Jesse Liberty is a great author. Programming C# is one of the finest programming books I’ve read.

  3. "Yes, I agree that the My keyword does improve RAD, but does it really add anything new? It seems more like a bunch of scattered methods aliased in one place, and managed methods, too."

    Adding new features and making existing features easier to use are two different things. The whole "My" concept is a pretty darn nifty–the idea is to save developers time by wrapping commonly used functionality that would normall take quite a few lines of code into a simple method call in most cases.

    "A C# programmer could encapsulate the functionality in a class and make their own "My" class which would provide equal RAD, plus the time it took to make it, but the developer would only have to make it once."

    You’re exactly right in your observation, I believe. You *could* write your own wrapper classes to do just the same thing, but why should you? I’m glad Microsoft is focusing on developer productivity these days and I welcome features like these.

    I just hope with the whole "My" slant toward VB development that the underlying method calls to framework libraries will be fairly easy to discover. Having good documentation from MSDN will be critical for those times when you’ll need to dig a bit deeper for functionality that might be excluded by the quest for RAD simplicity.

    Has MS given any consideration to throwing the whole "My" namespace up on to GotDotNet workspaces as a community project? This would definitely benefit all developers regardless of language choice–and give the community a wonderful foundation to build upon with similar new features.

  4. Jesse’s writing style is lucid. At the risk of sounding moronic, his C++ in 21 Days finally clarified pointers for me in a way that other books could not. Of course it took me a hell of a lot longer than 21 days to learn C++, but despite its title, the book was excellent.

  5. Just a quick note to thank you all for your kind comments You can find out more about my articles and books on my web site ( http://www.LibertyAssociates.com ) – just click on books and resources.

    I agree that my is nothing more (and nothing less!) than a set of convenience wrappers, but convenient they are. You can do the same thing for yourself in C#, or you can use the VB.NET library from C#, but neither is as easy as just using the My objects in VB.NET.

    Thanks.

    -j