Robert Green's Visual Basic Blog

VB Rocks!

Clarification on My

Previously on my blog I said
”The My namespace is really just wrappers around existing Framework classes.”

Jay Schmelzer of the VB team writes
It’s not a set of wrappers for the framework, it is a speed-dial into the framework that helps VB developers find commonly used framework classes. In many cases we will also return instances of the framework class that is initialized and ready to use. Printing is a great example of this. My.Computer.Printers.DefaultPrinter returns a System.Windows.Forms.Printing.SimplePrintDocument that is setup and ready to work with the Default Printer. You can absolutely do this directly with the framework, but to get the same functionality you need to create an instance of the System.Windows.Forms.Drawing.PrinterSettings class to determine which installed printer is the default printer and then assign it to the PrinterSettings property of the System.Windows.Forms.Printing.SimplePrintDocument you want to use. Not rocket science by any means but a few more lines of code that you don’t need to write and classes you don’t need to discover if you use the My.Computer route.

So my using “wrappers” is sloppy lingo. I guess I am just used to using that term to describe things that handle deeper levels of coding for me. At the NETDA meeting I think I compared it to the XML parser. I don't want to write my own XML parser. I want one written for me that I can Dim and then use the methods, properties and collections. I would want it to have a method called ReadXML and one called WriteXML. Happily, such a thing exists. And, happily, I can write my own if I want or need to. In my mind I see that as “wrapping“ all the plumbing code that is required to work with XML. I view My in the same vein. My.Computer.Printers.DefaultPrinter is clearly the default printer that belongs to the collection of printers that belongs to the computer that belongs to me. I don't want to necessarily have to figure out how to talk to the printer.

 

 

Published Wednesday, February 11, 2004 11:30 AM by rgreen_msft

Comments

 

Brian Desmond said:

I'm a VB type all the way, though I still am proficient in C# as I work with code that's written in it, get paid to use it sometimes, etc. Anyway, I find the statement "...and classes you don’t need to discover" a little annoying. Why would a developer *not* want how to do something directly?

It seems like a developer who has a more intimate knowledge of the framework would have more potential for exploiting its power.
February 12, 2004 7:02 PM
 

Robert Green said:

On the one hand I agree with you. It's just syntax. You can learn it. But on the other hand, we've heard from many people that the .NET Framework can be daunting to folks the first time they see it. We're trying to reduce the learning curve and provide ways to do the same things with less code. That is why we call My a speed-dial into the Framework.

We're providing a choice. Use the speed-dial, which uses the underlying Framework classes, or use the Framework classes directly. Your choice.

We want VB to have more of these types of choices. Drag and drop data and let us write the ADO.NET code for you or write it yourself or mix and match. Create your own library of reusable code or use ours (called snippets) or mix and match.

It's all about making the product more productive and less daunting to the new folks, without giving up any of the power. Using My should not be slower or less powerful. It is less code and more discoverable. But you get to choose to use it or the more "direct" way.
February 13, 2004 10:53 AM
 

Anand said:

Is there a way to extend the My namespace. What if I wanted a My.Computer.BlogReader for people who use my BlogReader(an ex, I dont have a blogreader)

I would say My is a very cool concept, but developers would surely like to extend it..
February 22, 2004 11:34 PM
 

Robert Green said:

You will be able to extend My. Stay tuned for more details.
March 3, 2004 8:12 PM
 

Mahavir said:

Please help me with the questions below :
May 25, 2004 8:03 AM
 

Robert Green s Visual Basic Blog Clarification on My | internet marketing tools said:

June 16, 2009 12:08 AM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker