Not at all - you SHOULD wrap your implementation details. What you
have is a model class in the MVC paradigm. Should you later wish, you
can replace the array with a different implementation without
breaking existing code; a problem were you ever to subclass an actual
array as nothing would prevent RS from changing something that would
cause your code to break.
This sort of thing would be greatly helped, however, if RB had an
equivalent to the C++ STL (Standard Template Library); that is - a
way to churn out a wrapper class for any datatype, just by filling in
the 'template' type at compile-time. Example: (doesn't compile - this
is just for argument's sake.)
Class ArrayWrapper <Type>
Dim theStuff(-1) As <Type>
Dim numElements As Integer
Public Sub ResizeMe(newNumElements As Integer, optional
eraseOnRedim As Boolean)
// resizing code
End Sub
Public Sub Item(Index As Integer, Assigns x As <Type>)
// setter method
End Sub
Public Function Item(Index As Integer) As <Type>
Return theStuff(Index)
End Function
// other methods as needed...
End Class
...
Dim myArray As ArrayWrapper[Integer]
myArray = New ArrayWrapper()
myArray.ResizeMe 5
myArray.Item(3) = 4
MsgBox "myArray(2): " + CStr(myArray.Item(2))
...
Of course you could use a Variant which would be the closest
'generic' solution as far as type-compatibility goes, but you would
still have to typecast any object references retrieved from the
array, as well as knowing which array elements held object references
so you could typecast them.
On Oct 23, 2006, at 1:57 AM, Jay Rimalrick wrote:
I am trying to make an iterator class. My plan is to
make a new class with an "array" as the super class
and then add some new "iterator" methods like java
has. However, I can't seem to get an array as the
super class. When I type array in the super class
text box it disappears and there is not an array
option to choose from the drop down box. RB is
obviously telling me that I can't use an array as a
super class, however what can I do to reach my
iterator ends?
I thought about making a new class with all of the
array methods simply "wrapped" in methods with exactly
the same name and then adding the iterator methods,
however this plan seems like a crude hack.
Thanks,
Jay
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>