Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 10th, 2009, 03:25 PM
Registered User
 
Join Date: Nov 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default OOP ASP question

I'm working on a class and I'm curious about setting properties values.

I'm just getting started in OOP and I'm using some online examples. I've been able to successfully incorporate 2 main classes into my application.

I'm curious about how to make this work or possibly a different method:

Code:
Public Class Foo
    Private privID
    Private privName
    
    Private Sub Class_Initialize()
        ' granted the pID isn't set yet, but maybe define another method to get it
        ' this was all just flying by the seat of my pants
        Call mGetName
    End Sub
    
    Public Property Get pID
        pID = privID
    End Property
    Public Property Let pID(value)
        privID = value
    End Property
    
    Public Property pName
        pName = privName
    End Property
    
    Private Sub mGetName
        ' some query here WHERE ID = pID
        privName = [query results]
    End Sub
End Class

Dim cFoo, Name
Set cFoo = New Foo
cFoo.pID = (Form/QueryString/Session)
Name = cFoo.pName

<%= cFoo.pName %>
Versus this idea:

Code:
Public Class Foo
    Private privName
    
    Public Property Get pName
        pName = privName
    End Property
    Public Property Let pName(value)
        privName = value
    End Property
    
    Private Function mGetName(value)
        ' some query here WHERE ID = value
        mGetName = [query results]
    End Function
End Class

Dim cFoo, Name
Set cFoo = New Foo
cFoo.pName = cFoo.mGetName(Form/QueryString/Session)

<%= cFoo.pName %>
Any advantage of one technique over the other? I'd imagine there are even other techniques.

Any insight is appreciated.

Last edited by LAYGO; November 10th, 2009 at 03:27 PM..
Reply With Quote
  #2 (permalink)  
Old November 10th, 2009, 03:32 PM
Registered User
 
Join Date: Nov 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess writing all that out & thinking about it more, the 2nd technique seems much more compact.

The one question I had (that I failed to ask) is how would a method define a property or several properties?

Code:
Public Class Foo
    Property p1
    Property p2
    ....
    Property pN
    
    Private Sub Class_Initialize()
        Call mGetProperties
    End Sub
    
    Private Sub mGetProperties
        ' query to get the data
        p1 = row1,col1
        p2 = row1,col2
        p3 = row1,col3
        .....
        pN = rowN,colX
    End Sub
End Class
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OOP Design Prob SiliconFuRy Java Basics 1 April 6th, 2006 03:01 PM
Classes (OOP) in VBScript 6 benr Pro VB 6 12 March 13th, 2006 04:02 PM
OOP design raj_sekhar C++ Programming 1 August 23rd, 2005 11:44 AM
OOP with JavaScript Moharo Javascript 3 September 29th, 2003 10:14 AM



All times are GMT -4. The time now is 10:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.