With the introduction of the My framework into the Visual Basic 2005 programming environment, Microsoft is hoping to significantly streamline the process of finding functions and resources. VB rose to the top among programming languages largely due to ease of use, and this trait did apply quite so well, many agree, when VB6 was transformed into VB.NET. Resource location is an area Microsoft is addressing as the second version of a .NET enabled VB environment comes forward.
"The top-level goal is to make it easier for application developers to accomplish common programming tasks, and by doing that, to expose the [.NET] in an understandable and consumable fashion," said Jay Schmelzer, lead program manager for Visual Basic at Microsoft. "We often refer to this as a speed dial into the .NET framework," he noted.
Schmelzer explained that Microsoft got a lot of feedback that the 2003 edition of Visual Basic sometimes made it difficult for programmers to find what they were looking for with the Namespaces framework. So the My namespace framework was created to help people find common functionality, like reading and writing to a text file.
In the 2003 VB edition, programmers would have to know that file systems could only be accessed under the I/O namespace. Programmers would sometimes have to navigate around the namespace hierarchy a few times before they found what they wanted.
The My namespace framework comprises a set of shortcuts to various kinds of functionality, in which programmers can access a particular feature or set of resources from a variety of places in the namespace. This is said to provide an intuitive way to find the functionality exposed by the underlying development framework.
Hello, Central! Program access, that is
In addition to core functionality, programmers can use My.resources to expose all of the resources in the project, such as forms, settings, configuration information, icons, and connection strings to databases from a single place at the top level. Schmelzer said it provides a centralized way to programmatically access all of the pieces of the application.
The framework also makes it easier to see the dependencies between classes, so that when programmers consider using a particular class, they can more quickly determine other classes they may need to include. For example, in the old edition, programmers writing code to read from a file, might not have immediately grasped that they also needed to create a stream object.
Developers can also add top elements to the My namespace. For example, if they were writing programs around devices, they could create a my.computer.device, which includes all of the different functions someone might call in talking to a mobile device or printer.
A user view
Bill Hollis, an author/consultant with Elysian Consulting in Nashville, TN,who has used the new tools said, "The My framework is a good start in the right direction. This lowers the bar for using some of the more advanced features."
His initial observation was that there are several things that programmers will use right away, such as accessing settings and resources, which were more difficult to get to in VB 2003. He noted, "I think this is a big step and will help a lot more programmers use those features more readily."
For example, getting information about the current computer used to require a pretty good run of code, which complicated simple tasks such as posting information to a log file. Hollis said, "Now you just refer to the My.net.username. When you are trying to insert that in a log message or pop-up dialog, it is easier to get to than it was before.
Hollis said the My.resources are particularly useful for programmers that have been doing this for a while. He noted, "Even experienced programmers did not use resources [very well], because they had to use a lot of arcane code."
For example, if you wanted to find out information about the current screen in previous versions of VB you had to access GDI, so the logic might be described as convoluted. Now you just query My.computer.screen. Hollis said, "I think it will be routine to use settings and resources this way except in very advanced scenarios."