Re: Object Orientation in VB.NET



"Persophen" <yerboln@xxxxxxxxx> wrote in message
news:1143567011.564893.192120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have got a program where I should extensively implement
object-oriented features of the vb.net. I have got a class tenant and a
class room, both belong to some dormitory. In that dormitory class i
have 2 array lists to store objects of class tenant and room
respectively. In class tenant I created association with the class
room, so I may see in which room every tenant lives. However I did not
create association in the room class in order to avoid data
duplication.

Instead if I want to lookup which tenant lives in some particular room,
I first get the room number from the rooms array list and then I lookup
the same room no in the tents list and retrieve the corresponding
tenant's name.

I am not sure whether this approach is fine, anyway it provides me info
I need. But I am not sure whether it is object oriented enough? Should
I create an association to tenant class in the room class?

Someone told me that class should be a complete entity and hold all the
info it is supposed to hold. I would like to get your opinion in that.

Contrary to what anyone may tell you, there are no hard-and-fast rules about
what data a class should hold. The idea is to use objects to make your life
simpler when solving a particular problem.

From the information you've presented it seems like tenant, room and dorm
are reasonable choices for classes but keep in mind that physical things are
not the only things that can be modelled by classes. For instance, in a
larger system you might have a class called "StudentList" that could be used
for various enrollment purposes.

Since we don't know what kind of algorithms you will run on your data
objects it's hard to say whether you should keep a tenant-list per room in
addition to the room association in the tenant class. If you do a lot of
searching it would probably be a good idea to keep the list that makes the
search fast, even if that does mean some data duplication and, more
importantly, maintaining the integrity of the list.

Andrew


.



Relevant Pages

  • Re: lot man
    ... >> occupations appearing (rather than the original hynd, herd, tenant, ... > this might be another source of names and occupations for you. ... > militia lists for Dundee, Forfar etc. (some in the Angus Archives, some ...
    (soc.genealogy.britain)
  • Re: Question: Implementing Object-Orientation in VB.NET
    ... both belong to some dormitory. ... have 2 array lists to store objects of class tenant and room ... is the class designer's business, ... I would have three lists in the dormitory, ...
    (comp.lang.basic.visual.misc)