473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Interface and overloaded functions in visual studio.NET

If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test
End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?
Is there a specific reason for this behaviour?
Nov 20 '05 #1
11 1463
"sotto" <ju**@sotto.invalid> schrieb
If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements
MyInterface.test End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test
End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?
Is there a specific reason for this behaviour?


If you've already got a procedure with the name "test", the IDE uses this
kind of numbering. In this case, it wouldn't be necessary, so you're right.
I'd post it again in microsoft.public.vsnet.ide.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* sotto <ju**@sotto.invalid> scripsit:
If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test

End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?

Is there a specific reason for this behaviour?


I currently don't have VS.NET 2003 here, but if it names it with an "1"
at the end of the name it is maybe a bug.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
> I currently don't have VS.NET 2003 here, but if it
names it with an "1" at the end of the name it is maybe a bug.
I use VS2003 and it does name overloaded interface methods with an number
suffix.

e.g.

Test()
Test1()
Test2()

etc.

Trev.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ez*************@TK2MSFTNGP10.phx.gbl... * sotto <ju**@sotto.invalid> scripsit:
If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test

End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?

Is there a specific reason for this behaviour?


I currently don't have VS.NET 2003 here, but if it names it with an "1"
at the end of the name it is maybe a bug.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
VS.net uses "proc", "proc1", "proc2" .... type naming when generating
function names for you. If it generates "proc", but that name already
exists, then it will try "proc1". If that exists, it will try "proc2", and
so on...

While the generator COULD use method overloads, overloading a method only
makes sense if the functions are closely related. VS.NET really doesn't
know if they're related or not, so it names them uniquely. This naming is
applied in all cases, even when using the same name isn't an issue.
"sotto" <ju**@sotto.invalid> wrote in message
news:G9*********************@hestia.telenet-ops.be...
If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test
End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?
Is there a specific reason for this behaviour?

Nov 20 '05 #5
Herfried,
As Trev stated, it "numbers" the members when they are overloaded, I suspect
for the reason Armin cited.

The numbering partially makes senses when the class had a Test function with
a different return type before I added the interface! I'm sure numbering is
the "easy way" to implement it. ;-)

However! more oft then not, I do not want the methods numbered, I either
want implicitly or explicit interface implementation (to borrow the C#
term).

' implicit interface implementation
Public Function test() As Boolean Implements MyInterface.test
End Function

Public Function test(ByVal MyVar As String) As Boolean
Implements MyInterface.test

Public Function test() As String
End Function

' explicit interface implementation Private Function MyInterface_test() As Boolean Implements MyInterface.test End Function

Private Function MyInterface_test(ByVal MyVar As String) As Boolean
Implements MyInterface.test

Also in this context the Overloads normally is not needed, I'm suspect its
injected incase I am implementing the interface in a class that already has
a Test method inherited from a base class.

Just a thought
Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ez*************@TK2MSFTNGP10.phx.gbl... * sotto <ju**@sotto.invalid> scripsit:
If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test

End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn't it just make a test() and a test(ByVal Myvar As string)
function?

Is there a specific reason for this behaviour?


I currently don't have VS.NET 2003 here, but if it names it with an "1"
at the end of the name it is maybe a bug.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
The numbering partially makes senses when the class had a Test function with
a different return type before I added the interface! I'm sure numbering is
the "easy way" to implement it. ;-)
Seems to be a "quick and dirty" solution...

;-)
However! more oft then not, I do not want the methods numbered, I either
want implicitly or explicit interface implementation (to borrow the C#
term).


I don't like numbered methods too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7
Herfried,
Aren't "easy way" and "quick and dirty" synonyms?

:-))

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bu************@ID-208219.news.uni-berlin.de...
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
The numbering partially makes senses when the class had a Test function with a different return type before I added the interface! I'm sure numbering is the "easy way" to implement it. ;-)


Seems to be a "quick and dirty" solution...

;-)
However! more oft then not, I do not want the methods numbered, I either
want implicitly or explicit interface implementation (to borrow the C#
term).


I don't like numbered methods too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #8
Cor
Hi Jay B,

I hope you don't mind I answer also?
Aren't "easy way" and "quick and dirty" synonyms?


I think not, they are opposites in my eyes.

Keep it simple is not only a term I often use.

If you cannot "Keep it simple", the "quick and dirty" way is mostly the bad
solution.
(About that we do not have to argue).

Just a thought,

Cor
Nov 20 '05 #9
> Aren't "easy way" and "quick and dirty" synonyms?

"easy way", "quick and dirty" and "quick and beautiful" are in the eyes of
the beholder ;)
Nov 20 '05 #10
Cor,
What's that saying about if you have to explain a joke? :-|
Joking aside: I hope you realize that "easy way" is not necessary "keep it
simple", in the context I was using it "easy way" is the path of least
resistance, the quick way for the Microsoft employee. The "quick & ..."
way... At least from my perspective & understanding of compilers.

Also "keep it simple" for who the Microsoft employee or for the target
audience the non-Microsoft developer who uses VB.NET?

As Trev stated its in the "eye of the beholder", and I'm adding its a matter
of perspective. Either Microsoft the developer of the language or Us the
consumer of the language...

Think about, in some cases, how much effort you need to code, to get
something "real simple" for the user of your program. Or when you take the
easy programming route, how much work more work the user of your program
has.

Note I am not disagreeing you with, I am just trying to point out the
perspective I used in the statement.

Just a thought
Jay
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Jay B,

I hope you don't mind I answer also?
Aren't "easy way" and "quick and dirty" synonyms?
I think not, they are opposites in my eyes.

Keep it simple is not only a term I often use.

If you cannot "Keep it simple", the "quick and dirty" way is mostly the

bad solution.
(About that we do not have to argue).

Just a thought,

Cor

Nov 20 '05 #11
Cor
Hi Jay,

You know we agree, but I have seen to much solutions on the difficult way,
which did not add anything to what you are saying (and as you know I agree).

I thought, we both think the same in this matters, but I brought it in to
tell that the "difficult" way is not always the best solution.

Quick and dirty is in my opinion only allowed as a patch when there is
really nothing else, mostly it never changes and gives you trouble on then
next version of the OS or the compiler.

(Was a discussion also in this newsgroup when somebody said, never fix it if
is not broken, that I also not agreed, you have to do maintanance if the
economic cost of something has reached the break even point)

That is what I think about it.

To recapitulate the difficult way is not always the best way, quick and
dirty is always the worse way.

If you do not disagree, and I think so, no need to answer.

Cor
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Angus Leeming | last post by:
Dinkumware's online STL reference http://tinyurl.com/3es52 declares std::map's overloaded erase member functions to have the interface: map::erase iterator erase(iterator where); iterator...
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
2
by: Todd Brooks | last post by:
I have a coclass that implements a dual interface. The thing that's a little unusual is that the coclass doesn't inherit directly from the interface, rather it inherits from an implementation class...
0
by: Mark | last post by:
I create a simple interface in a com object: public interface ISimple { void a(); int b(); } I build the object in Visual Studio and load the object from Excel. I can call a and b...
4
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am developing website application in asp.net , visual C# and atl com. I am using atl com component in visual C# application. One of the function of com component interface returns...
1
by: mersinli | last post by:
Hi, I have got seven error and I dont find why compiler find error.. //commission class definition #ifndef COMMISSION_H #define COMMISSION_H #include <string> using std::string;
2
by: SlimT88 | last post by:
I recently created a simple class for a homework assignment and ran into compilation errors concerning overloaded global functions. I've copied the relevant parts of my code below and the errors...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
7
by: Random.Coder | last post by:
The output of this simple program below differs if it's compiled in Visual Studio 2005 and 2008. Is one the correct output, and if so, why? using System; namespace DerivedTestApp { class...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.