OOP Design Question
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngarchitecture' list.


Mark Feinholz
I've got what must be a classic object design issue that has been solved
many times.

I'm building a time tracking system. To simplify a bit there are
Projects and Resources that work on the projects.

A Project has Resources assigned to it, therefore the Project object has
a Resources property implemented as a collection of Resource objects.

A Resource has Projects assigned to them. Therefore the Resource object
has a Projects property implemented as a collection of Project objects.

So depending the context, each of these objects has at least one
collection property that won't be used. My question is, does it makes
sense to create a base class for Project that does not include the
Resources collection/property and create a base class for Resource that
does not include the Projects collection/property and then extend these
classes with a ProjectResource class and a ResourceProject class which
do contain their respective collection properties?

Mark.
Reply to this message...
 
    
Francesco Sanfilippo
When a Project is constructed, won't the Resources collection remain null if
there are no Resources, and vice versa with the Projects collection of the
Resource object?

FS

[Original message clipped]

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply to this message...
 
    
Francesco Sanfilippo
How are your Collection properties implemented? As ArrayLists?

FS

[Original message clipped]

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

Reply to this message...
 
    
Francesco Sanfilippo
I am building an OO Business Logic Tier in C# for a big .NET application, a
community web site, ala Yahoo and MSN (but not quite that big). A core
object is the Member class, representing a signed in Member of the site.
When the Member object detects a sign-in, it loads some data for a user that
is used in a Control Panel type region, with live statistics. As users
click on links for details about control panel items (such as: newsletters
they belong to, emails they have received since last sign in, friends of
theirs that are online) the data is dynamically loaded from a SQL Server.

Here's an example of a sample conundrum I am in:

A Member has a MemberAddress property which is a custom class called
MemberAddressCollection. MemberAddressCollection has an ArrayList as a
property, and that ArrayList holds MemberAddress structs which each
represent a single adress book entry. The MemberAddressCollection also
holds methods for Select/Insert/Update/Delete.

Does this seem like a good design? I have heard so much about Collections
of objects acting as a property to a static class.

Francesco

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
    
John R. O'Brien
I think you're right in having the collections as part of the objects as
you describe. I'm not sure that that is the reason for a base class,
but It's ok if the collections are empty if the objects are in some
intermediate state.

The second thought you discuss, of ProjectResource and ResourceProject
classes, I think is related more to a relational database design, and
maybe if your are persisting information in an sql database that is the
join table that you can use to populate the collection information.

Remember my advice is free and has no express warranty, anyway that's
the way I see your ideas. They are correct as you have described them.
Use the second idea for designing a relational database.

John R. O'Brien
Home 410 352 3614
Cell 443 497 2017
FAX 801 849 7589

-----Original Message-----
From: Mark Feinholz [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 4:27 PM
To: aspngarchitecture
Subject: [aspngarchitecture] OOP Design Question

I've got what must be a classic object design issue that has been solved
many times.
I'm building a time tracking system. To simplify a bit there are
Projects and Resources that work on the projects.
A Project has Resources assigned to it, therefore the Project object has
a Resources property implemented as a collection of Resource objects.
A Resource has Projects assigned to them. Therefore the Resource object
has a Projects property implemented as a collection of Project objects.

So depending the context, each of these objects has at least one
collection property that won't be used. My question is, does it makes
sense to create a base class for Project that does not include the
Resources collection/property and create a base class for Resource that
does not include the Projects collection/property and then extend these
classes with a ProjectResource class and a ResourceProject class which
do contain their respective collection properties?
Mark.
| [aspngarchitecture] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngarchitecture.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Mark Feinholz
Every object inherits from a custom base BusinessObject class and every
object has an associated collection object that inherits from a custom
base BusinessObjectCollection class. The BusinessObjectCollection class
inherits from System.Collections.CollectionBase... So yea the collection
properties are implemented as ArrayLists, but indirectly thru
CollectionBase.

To answer your other question, yes, the Resources collection will be
empty on a Project object that was instanciated as part of a Projects
collection that is a property of another Resource object (that bizarre
description was from the bottom up in the hierarchy... Another way to
say that is if the top level object in the hierarchy is a Resource, then
it will have a Projects collection containing Project objects. Each
Project object in that collection will be a Project object whose
Resources collection will be empty.

I'm just wondering if it makes sense to not expose the Resources
collection at all in this case since it will never contain anything. It
creates a bit of a weird inheritance structure though - with funny named
classes.

Mark.

-----Original Message-----
From: Francesco Sanfilippo [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 7:06 PM
To: aspngarchitecture
Subject: [aspngarchitecture] Re: OOP Design Question

How are your Collection properties implemented? As ArrayLists?

FS

[Original message clipped]

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

| [aspngarchitecture] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngarchitecture.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 
System.Collections.ArrayList
System.Collections.CollectionBase




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com