HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

VbScript/ASP Classic good OOP Pattern

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
vbscriptclassicpatterngoodaspoop

Problem

I have to create a website in Classic ASP, and I really want to do a clean design so I will try to put everything in Classes and Models to emulate the ViewModel Pattern.

So can you tell me if this approach of creating objects is good because I will use it everywhere

Class User
    Public Name
    Public Adress
    Public Title
    Public Text 
    Public Rights 'ArrayList of Right objects

    Private Sub Class_Initialize()
       Initialize
    End Sub

    Private Sub Class_Terminate()
       Dispose
    End Sub

   Private Sub Initialize()
       Name    = ""
       Adress  = ""
       Title   = ""
       Text    = ""
       Set Rights = Server.CreateObject("System.Collections.ArrayList") ' Arraylist .net
   End Sub

   Private Sub Dispose()      
   End Sub

End Class


Class Right

    Public Name

    Private Sub Class_Initialize()
        Initialize
    End Sub

   Private Sub Class_Terminate()
       Dispose
   End Sub

   Private Sub Initialize()
       Name    = ""
   End Sub

   Private Sub Dispose()      
   End Sub
End Class


And then I do this for instantiating objects :

Dim myUser 
Set myUser = New User

'Do some work

Set myUser = nothing 'Dispose the object


Any idea, suggestion or correction is welcome.

Solution

I am not a big VB person, but I would think that if you give your class a Dispose method you should use it rather than setting it to nothing, I know this is kind of the same thing, but if you aren't going to use the Method don't create the method, it's extra stuff. if you are going to use it in the future, comment to that effect.

'This Method is for future development
Private Sub Dispose()
End Sub


OR

'TODO: Implement!
Private Sub Dispose()
End Sub


my comment syntax is probably off a little bit.

Code Snippets

'This Method is for future development
Private Sub Dispose()
End Sub
'TODO: Implement!
Private Sub Dispose()
End Sub

Context

StackExchange Code Review Q#15300, answer score: 2

Revisions (0)

No revisions yet.