Re: vb.net class
- From: "_AnonCoward" <abc@xxxxxxx>
- Date: Tue, 23 Aug 2005 20:04:19 GMT
<thomasp@xxxxxxxxx> wrote in message
news:430b760e$0$6979$b9f67a60@xxxxxxxxxxxxxxxxxxxxx
:
: Alan,
:
: Thanks for all the comments
<snip>
: *********************************************************************
: - If possible, an arraylist is simpler for working with. It will
: not impact this class but when generating the inputs an arraylist will
: probably make things easier.
: ***************************************************
: I will read about the arraylist I have never used
: one
: ***************************************************
They are handy. They are sized dynamically so you don't have to worry
about fixed array lenghts or using ReDim statements. That said, they do
have one serious downside in my opinion - they aren't type safe. Your
code ensures everything in the array is a String because you declare it
as such. However, an array list can contain literally any type of
object. If you don't have control over how the array is formed, this may
work against you.
: - Calculate the properties when needed instead of generating them
: at time of construction. You may not always use both
: - you will need to either store a reference to the incoming
: date/times (if you want the average/span to update if you change any
: of the original values)
: or, copy the values if you want a snapshot view.
: *********************************************************************
: Not sure about this. The records are gathered and the array
: is filled at the start of the sub. The class is declared later and
: the values of each of the properties are used as strings in the
: construction of the text of the report. I guess readonly properties
: would be fine. I will have to read on how to make them readonly
: *********************************************************************
Public Readonly Property PropertyName() As SomeType
Get
Return SomethingHere
End Get
End Property
: 2)
: Private _Count As Integer
: Private datFirst As Date
: Private datLast As Date
: Private intFirst As Integer = 0
: Private intMinute As Integer = 0
: Private intSecond As Integer = 0
:
: do not need to exist at the class level
: ***********************************************
: is it better to declare them in each function
: or declare them once at the class level. Seems
: easier to me to declare them at the class level
: ***********************************************
Member variables are created on the heap when the class is instantiated
and the memory consumed is not released until the garbage collector
runs. This can become have an undesirable impact on memory resources -
if you have a large number of instances of this class, each one of them
will create space for those variables. Since you don't need them outside
of the functions that use them, keep them there. This way, multiple
instances of the class don't use up memory they don't need.
: 3) Properies
:
: Count can be generated from the time list, not need to store
: It should be read only
:
:
: AvgTime and TimeSpan should both return TimeSpan
:
: They both should be read-only
: If allowing the inputs to be modified then you will want to
: recalc them every time (no variables to store them,
: Private _AvgTime As String
: Private _TimeSpan As String
: both disappear) or else you calc them only the first time they
: are used, store them in the class and each subsequent time,
: return the stored value.
: *************************************************************
: Ok, I am very confused on all of the property stuff. I will
: have to do some more reading on it.
: *************************************************************
The primary value of properties from my perspective is that they isolate
your member variables. For example, they can restrict access by making
them read only (as Alan is suggesting). You can also screen the values
submitted as I suggested previously. If you want to allow the variables
to be set by the consumer of the class, you can still prevent invalid
values from being passed in.
<snip>
Ralf
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.
.
- References:
- vb.net class
- From: thomasp
- Re: vb.net class
- From: alantolan
- Re: vb.net class
- From: thomasp
- vb.net class
- Prev by Date: Re: Select from DataTable
- Next by Date: Re: Accessing a Shared Variable
- Previous by thread: Re: vb.net class
- Next by thread: Re: vb.net class
- Index(es):
Relevant Pages
|