Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Using Properties vs Function


Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2002, 09:12 PM
Ryo2
Guest
 
Posts: n/a
Default Using Properties vs Function


I'm creating a class module and I'm debating whether to use properties (Get) or functions to return some simple values. I just wanted some input to determine which would be more efficient.

Thanks.
Reply With Quote
  #2  
Old 07-16-2002, 09:28 PM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

For simple values, there probably isn't any difference in efficiency.
I prefer to use properties if either one would do the same thing.
__________________
Posting Guidelines
Reply With Quote
  #3  
Old 07-16-2002, 09:31 PM
Genna
Guest
 
Posts: n/a
Default

actually it depends on situations
if my values are static, i would use the properties
otherwise, it would be functions, functions do shorten your coding.
I used to have an application which is about 19 pages until my friend told me to use functions
now it is around 5 pages *wickedly grinz* :>
it is still growing :>
Reply With Quote
  #4  
Old 07-16-2002, 09:33 PM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

Whether or not the values are static has nothing to do with using
properties or methods. If you don't know something about the
question, please don't post.
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 07-17-2002, 11:51 AM
Ryo2
Guest
 
Posts: n/a
Default

Thanks Thinker.

Genna: BTW maybe you got it confused with another thing. It doesn't shorten my code whether I use Properties (Let/Get) vs Functions.

Here's a simple example:
Public Property Get MyNameProp() as String
MyName = "SOME STRING"
End Property

Public Function MyNameFunc() as String
MyNameFunc = "SOME STRING"
End Function
Reply With Quote
  #6  
Old 07-17-2002, 11:57 AM
Banjo's Avatar
Banjo Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

The way I tend to distinguish between the two is to ask this question:

Does it specify information or operate on information?

The former becomes a property and the latter becomes a method.
That doesn't preclude properties from operating on the data they are setting but I normally limit it validation checks and the like.
__________________
A wise one man once said "what you talking about dog breath"
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->