My oh My
Nothing kills the enjoyment of new cool features in a release like learning about the even cooler features in the next release. But in the world of computing, we have been getting used to this.
.NET provides a great new class libary, so great in fact that even experienced VS programmers will have a hard time learning to know it. The hierarchy is not necessarily intuitive, either (nothing is) and there are often several places where you find similar functionality.
For Visual Studio 2005, Microsoft has tried to improve this by adding the new My namespace.
Now, I was never a fan of the "My computer", "My pictures" and "My whatnot" that Microsoft has added all over Windows. I prefer the file and folder structure, thank you, and please leave the network settings where God intended them to be.
However, I have to admit that the new My namespace sounds like a great idea for providing shortcuts to classes and functionality in a logical and (ahem) intuitive fashion.
The two examples given my Microsoft really does not need any improving. Earlier (well, now), to read the content of a text file into a variable, you do something like this:
Dim sr As New IO.StreamReader("c:\file.txt") contents = sr.ReadToEnd sr.Close()
There is nothing wrong with this, and a good improvement on earlier file access systems. However, add zillions of classes, and it becomes really hard to rememebr everything.
This is how it's done with the new My namespace:
contents = My.Computer.FileSystem.ReadAllText("c:\file.txt")
Well, say what you want, it is a neat idea. I'm sure you'll enjoy reading the whole article.
By organising everything in a logical hierarchy that reminds people about the way a typical Windows user sees the hardware and software, it should make it easier for programmers.
My exposes several distinct classes which organize a variety of functions into one of seven general areas: My.Application, My.Computer, My.Forms, My.Resources, My.Settings, My.User, and My.WebServices.
I'm sure there will be similar problems knowing which classes belongs where, but those can never be fully avoided, and since these are shortcuts, I assume they can be duplicated (?). I am glad the Visual Studio developers have not stopped innovating and thinking in new and exciting ways.
Bonus: Anand M about how to extend the My namespace.
More: Application level events! (in VB but apparently not C#)
3:02:19 AM
|