S
Stefan
Could someone please explain if there is a difference between when one
should use the word method or function. Do they have the same meaning?
should use the word method or function. Do they have the same meaning?
Jay B. Harlow said:Like Tom I use method for either Sub or Function.
I will also use method to mean Property procedures as well.
The way I view it is: Sub, Function & Property are types of methods. So I
use method when I want to be generic, I use Function when I need to be
specific.
Jay B. Harlow said:Although I agree with you 100%.
You did notice I was specific to say Property _Procedures_
(by Procedure I mean the Get & Set assessors) and not just
Property. As the Get & Set assessors have statement blocks aka action.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfVBSpec7_6.asp
The problem is Properties are in that grey area where they're both.
Depending on what aspect of a property you are referring to.
The property itself is an attribute, while the get & set assessors are
'actions', which can be Overridden.
For example, You can apply the ConditionalAttribute to any method. This
includes the Get or Set assessor of a Property.
Property Name() As String
<Conditional("DEBUG")> _
Get
return m_name
End Get
<Conditional("DEBUG")> _
Set(ByVal value As String
m_name = value
End Set
End Property
Of course the above Get will not have the desired effect as its returning a
value, and needs to be called in all cases...
Which is where generically I will include Property Assessors as methods. At
the same time generically I include Properties as attributes.
Tom Spink said:The term attribute does tend to confuse, as that's what the < and > are
called:
<StructLayout(Foo)> Public Structure Bar
Public Baz As Moo
End Structure
The <StructLayout(Foo)> is an attribute, that's what microsoft calls it.
When are they not a member of a class? Module & Interface perhaps? INotice that I am not a native English speaker, maybe I am misinterpreting
the meaning of method, procedure, and attribute. Why not use the terms like
that:
method: Sub, Function (if they are members of a class)
procedure: Sub, Function, Property (Get, Set)
attribute: Property
Tom Spink said:My response was a joke, e.g. we cannot yet perform operator overloading, so
why should we be able to overload attributes, even though it makes no
sense.... <g>
Jay B. Harlow said:When are they not a member of a class? Module & Interface perhaps? I
consider them methods in any Type (Class, Module, Interface, other).
For me method & procedure are synonymous (have the same or very nearly the
same meaning). Overall I consider procedure a type of method.
For me: Procedure is a carry over from RPG, COBOL, VB1 -
VB6 days, while Method is a carry over from C/C++/Java OOP
days.
ACK.
Because I favor OOP over VB6, I will tend to use method over
procedure. When I use procedure it will generally be in a
VB6 context.
;-)
As you said Methods are actions, Property Get is an action &
Property Set is an action.
I consider both properties & fields to be attributes (lower case a).
ACK.
While an Attribute (upper case A) adds meta data to any member
or type.
Cor said:I think this can be an endless discussion but important is in
my opinion again what language are you using (speaking).
My child name is Kok and from my sister Con.
My mother is not speaking any language.
?!?
You should have seen the faces from the french people when
my mother was calling us on the camping where we where
when I was young.
I think that when I am thinking in VB I use the word function
when I am talking about functions like Mid, Len and even String.
I then am talking about methods when I use things like
String.substring.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.