473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Object structure question

Jon
I have an object in my program that represents a movie. As part of that
objects properties, I would like to have the "cast" of the movie. I am not
sure whether I should simply make a public array variable to hold them or a
collection or even a property that is an array. I've never made a property
that was an array, so I'm not very sure how to declare it, if I were to use
it. Could someone push me in the right direction and offer a bit of advice?
Thank you

--
********************************
Jon Rosenberg
www.DeanForAmerica.com
www.OhioForDean.org
Nov 20 '05 #1
4 967
* "Jon" <ru******@msn.com> scripsit:
I have an object in my program that represents a movie. As part of that
objects properties, I would like to have the "cast" of the movie. I am not
sure whether I should simply make a public array variable to hold them or a
collection or even a property that is an array. I've never made a property
that was an array, so I'm not very sure how to declare it, if I were to use
it. Could someone push me in the right direction and offer a bit of advice?


What do you want to store in the cast "array"? Objects of a certain
type?

This code will create a property which returns an array:

\\\
Private m_Cast() As String

Public Property Cast() As String()
Get
Return m_Cast
End Get
Set(ByVal Value As String())
m_Cast = Value
End Set
End Property
///

I think it's better to use an 'ArrayList' or even better a type-safe
collection to store the items.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
"Jon" <ru******@msn.com> wrote in message
news:vu************@corp.supernews.com...
I have an object in my program that represents a movie.
As part of that objects properties, I would like to have the
"cast" of the movie. I am not sure whether I should simply make
a public array variable to hold them or a collection or even a
property that is an array.


Anything Public is uncontrolled (by your class) and, therefore,
inherently "dangerous". Somebody could do something like this:

Class Movie
Public Cast() as CastMember
. . .
End Class

BitOfFun = New Movie( "Terminator", 3 )
BitOfFun.Cast( 0 ) = New CastMember( "Charlie Chaplin" )

Perfectly valid, but I don't think the action sequences would be
quite the same. ;-)

It would be better wrap the [private] cast members (/however/
you choose to store them) with a [read-only] public property.

HTH,
Phill W.
Nov 20 '05 #3
Jon
Thanks for your answer. The array will be a listing of the name's of the
cast members of the movie. So, it will be several text objects.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
* "Jon" <ru******@msn.com> scripsit:
I have an object in my program that represents a movie. As part of that
objects properties, I would like to have the "cast" of the movie. I am not sure whether I should simply make a public array variable to hold them or a collection or even a property that is an array. I've never made a property that was an array, so I'm not very sure how to declare it, if I were to use it. Could someone push me in the right direction and offer a bit of
advice?
What do you want to store in the cast "array"? Objects of a certain
type?

This code will create a property which returns an array:

\\\
Private m_Cast() As String

Public Property Cast() As String()
Get
Return m_Cast
End Get
Set(ByVal Value As String())
m_Cast = Value
End Set
End Property
///

I think it's better to use an 'ArrayList' or even better a type-safe
collection to store the items.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
* "Jon" <ru******@msn.com> scripsit:
Thanks for your answer. The array will be a listing of the name's of the
cast members of the movie. So, it will be several text objects.


Then a string array is a good solution if the data doesn't (often) change in the
lifetime of the object.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Olivier Jullian | last post by:
Hi, I'm new to .NET and am trying to take advantage of the object structure while accessing relational databases. I started a small project for managing "projects". Here is a description of...
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
3
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL,...
11
by: jacob navia | last post by:
I am writing software to make a general storage facility of any kind of objects to/from disk. The intermeidate format used is XML, using the schema (modified a bit) of Microsoft:...
2
by: Frank | last post by:
Hello, I use the tag of a textbox to store the address of a structure: uFormTag = New formTag() Me.Tag = uFormTag First question: is that the rigth way to do it? Or should it be ...
33
by: Frederick Gotham | last post by:
(My dialect of English seems to puzzle people at times, so I'll first clarify a few terms which I use in the following post:) (1) By "domestic", I mean "ordinary, run-of-the-mill, not...
3
by: Patient Guy | last post by:
Subject line would seem to say it all: How does one trigger the execution of a method within an object or any other code/function with the setting of an object property? More elaboration for...
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
1
by: mirandacascade | last post by:
1) Module1 has the following delcaration: Public g_frmZZZ as Form Public g_txtForm2 as Variant 2) app has two forms: form1 and form2 3) a command button on form1 opens form2; it also has...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.