Who uses the My stuff - and why?

  • Thread starter Thread starter Tom Shelton
  • Start date Start date
Tom --

Tom Shelton said:
Just wondering? :)

I use 'My.Settings' and 'My.Resources' because both are really easy to use.

In addition, I use other methods provided by 'My' which are otherwise not
available in the .NET Framework, such as file copying showing the shell's
dialogs.

However, I disable 'My' features in class library projects because they
often do not make much sense there.
 
Tom --



I use 'My.Settings' and 'My.Resources' because both are really easy to use.

In addition, I use other methods provided by 'My' which are otherwise not
available in the .NET Framework, such as file copying showing the shell's
dialogs.

However, I disable 'My' features in class library projects because they
often do not make much sense there.

Ok.. Sounds reasonable. There just seems to be a lot of stuff that My makes
more difficult or just hides. So, I was curions what parts of it people find
useful :)
 
Tom,

Tom Shelton said:
Ok.. Sounds reasonable. There just seems to be a lot of stuff that My
makes
more difficult or just hides.

Could you provide some examples? Just wondering...
 
I'm using My.Computer.FileSystem to standardize file operations. After many
years (starting with vb6), I was using a hodge podge of different file
functions, all doing similar things. Now they all use My.Computer.FileSystem.

My.Computer.FileSystem was not the only way to standardize - its just the
way I chose. I haven't been forced to use 'My' because it was the only way
to get something done. There may be such a thing, but I don't know what it
might be.
 
As Herfried mentioned, I find the My.Settings and My.Resources a nice
shortcut. I have used some of the filesystem shortcuts to get the path to
"My Documents", "My Pictures" etc etc as well.

When doing quick proof-of-concept stuff I've found it handy to use some of
the filesystem operations, for example blasting out a load of text to a
file. For production code I prefer the long winded approach as I find it
makes more sense, particularly with error handling etc.

Used the My.Computer.Network.DownloadFile in production code once. Sheesh,
never again...

Cheers,
Alex
 
My.Resources makes it almost trivially easy to embed resources in your
applications. I have code lying around from before that does it the regular
way, but it's just complicated enough that I can never remember how to go
about it and always have to go looking for an example before I can code it
up. The My.Resources way is so easy and intuitive that there's no need for
that, especially because it's tightly bound to your resource files so you
get Intellisense. Consequently I do it a lot more than I used to.

So far that's the only thing out of the My namespace that I use. I've been
doing .Net since it first came out from under non-disclosure in the summer
of 2000 and I know the libraries pretty well, so there's no need to look for
another way to do something that I'm already comfortable with. But I'm
always ready for something that makes my job easier and faster.

Tom Dacon
Dacon Software Consulting
 
Tom,



Could you provide some examples? Just wondering...

Hmmm... It's probabaly just me :) I don't know, it just seems wrong to me
somehow. I mean, why would you do:

My.Computer.FileSystem.WriteAllText

when you can do

File.WriteAllText?

I don't know - it just seems like it's sometimes more trouble then it's worth.
 
Sanders Kaufman said:
I *started* to use My Services, but then I read something somewhere that
Microsoft said it was phasing it out.

I consider this unfounded rumor.
 
Sanders

Do you have a link to this. It is very hard to believe that Microsoft would
do this. Something eare his kind of considerations on Internet by
individuals.

This would mean that they should make a lot of effort to make a converter.
They did for VB6, but as you see what people wrote who in fact were using
VB6 with all kind of direct Win32 API code, they never succeeded in that.

The "my" class is a kind of handshake for those VB6 writters who do not
direct understand the distinct between a Class (Type) and an Object, which
is in VB6 not so clear as in Net.

However, that "my" will be removed again is almost impossible to believe
after the echec after VB6.

Just my opinin,

Cor
 
Tom Shelton said:
Just wondering? :)

The My.Settings and My.resources are so easy to use that I would not think
of doing it any other way now.
I have also used My.Computer.Network (download file, isconnected) for a
connection diagnostic app as sometimes it gives wierd replies which can be
useful to compare with other methods.
 
Some makes sense while other things do not. I decided to add my wrapper
functions like the one below to my default WinForm project.

Partial Friend Class MyApplication
Public Function Question(ByVal QuestionText As String) As Boolean
Return (Windows.Forms.MessageBox.Show(QuestionText,
My.Application.Info.Title, Windows.Forms.MessageBoxButtons.YesNo,
Windows.Forms.MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) =
MsgBoxResult.Yes)
End Function
...
End Class
 
| Partial Friend Class MyApplication
| Public Function Question(ByVal QuestionText As String) As Boolean
| Return (Windows.Forms.MessageBox.Show(QuestionText,
| My.Application.Info.Title, Windows.Forms.MessageBoxButtons.YesNo,
| Windows.Forms.MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) =
| MsgBoxResult.Yes)
| End Function

That is a real mess. Managed code indeed.
 
C Kevin Provance said:
| Partial Friend Class MyApplication
| Public Function Question(ByVal QuestionText As String) As Boolean
| Return (Windows.Forms.MessageBox.Show(QuestionText,
| My.Application.Info.Title, Windows.Forms.MessageBoxButtons.YesNo,
| Windows.Forms.MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
=
| MsgBoxResult.Yes)
| End Function

That is a real mess. Managed code indeed.

It's not required to use the long form, "Windows.Forms...", etc. Imports
statement can be used to "open up" that branch and use the functionality
within it in a particular source file. Example(air code):

Before:

Windows.Forms.MessageBox.Show(...)

After:

Imports Windows.Forms

MessageBox.Show(...)

Also, an alias can be used as a short hand version of the long name:

Imports wf=Windows.Forms

wf.MessageBox.Show(...)

Imports Statement
http://msdn.microsoft.com/en-us/library/7f38zh8x.aspx
 
Fair enough. I can see where that would save some typing. But still, good
old classic VB never needed so many dots.

| message | >
| > | > | Partial Friend Class MyApplication
| > | Public Function Question(ByVal QuestionText As String) As
Boolean
| > | Return (Windows.Forms.MessageBox.Show(QuestionText,
| > | My.Application.Info.Title, Windows.Forms.MessageBoxButtons.YesNo,
| > | Windows.Forms.MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2)
| > =
| > | MsgBoxResult.Yes)
| > | End Function
| >
| > That is a real mess. Managed code indeed.
|
| It's not required to use the long form, "Windows.Forms...", etc. Imports
| statement can be used to "open up" that branch and use the functionality
| within it in a particular source file. Example(air code):
|
| Before:
|
| Windows.Forms.MessageBox.Show(...)
|
| After:
|
| Imports Windows.Forms
|
| MessageBox.Show(...)
|
| Also, an alias can be used as a short hand version of the long name:
|
| Imports wf=Windows.Forms
|
| wf.MessageBox.Show(...)
|
| Imports Statement
| http://msdn.microsoft.com/en-us/library/7f38zh8x.aspx
|
|
 
Fair enough. I can see where that would save some typing. But still, good
old classic VB never needed so many dots.

Depends... It depends on the object model of the component that your using.
 
Michael D. Ober said:
Since we're in VB.NET:

Partial Friend Class MyApplication
Public Function Question(ByVal QuestionText as String) as Boolean
Return MsgBox(QuestionText, vbYesNo or vbQuestion or
vbDefaultButton2) = vbYes
End Function
End Class

In C#, you would be correct that it's a mess. Use the VB language to your
advantage, especially if you are already using the My class functions.

In C#, "using" Directive is the same as "Imports" in VB, including defining
aliases.

using Directive (C# Reference)
http://msdn.microsoft.com/en-us/library/sf0df423.aspx
 
Back
Top