Best OOP design move?

Best OOP design move?

Old forum URL: forums.lhotka.net/forums/t/1893.aspx


JCannelos posted on Sunday, December 03, 2006

Guys,

Hopefully this is an easy one. Web app:

I have to keep track of a list of Consultants and their details:

Consultants --> BusinessListBase<Consultants, Consultant>

I also need to keep track of Assets each Consultant has. I realize the whole assignment paradigm Rocky talks about, but I want to be able to do two things:

1. First, just show an editable list of Assets so they can be managed.

2. Next, show the same page, but only after someone asks to see a specific Consultant's Assets.

Right now, I have number 1 taken care of with this:

Assets --> BusinessListBase<Assets, Asset>

But what is the best way to handle #2? Should I do another constuctor on Assets where I pass in the Consultant? I was planning on having each Consultant have its own Assets collection, but then Assets needs to become a switchable object and I've heard thats bad. Any thoughts?

Hmmmm.. the more I think about it, a Consultant would have AssetAssignments, rather than the Assets themselves, right?

Thanx a bunch!

J'son

Wal972 replied on Sunday, December 03, 2006

A consultant would have AssetAssignments because the use is different. Also it would keep it clean

JCannelos replied on Monday, December 04, 2006

Ok, thanx... another question related to Consultants:

By the time I am editing Asset Assignments for a Consultant, I am down to the Consultants --> Consultant --> AssetAssignment level, with both Consultant AND AssetAssignments marked as Child. So that means I'll need to pass the entire Consultants collection in Session and call Consultants.Save() (the topmost level), even when I feel like I should be able to call just Consultant.Save() to save Asset Assignment changes.

Since Asset Assignments happens on a different web page from where I list Consultants. I was thinking of doing having a ConsultantList with readonly ConsultantInfo objects. When the user wants to Edit a Consultant, at that point I load a non-Child Consultant object for editing. That would allow me to edit and save Asset Assignments from the Consultant object rather than from the higher Consultants object.

Is this a cleaner design or am I just nit picking at this point?

Thanx!

J'son

ChristianPena replied on Monday, December 04, 2006

J'son,

I think your intuition is correct and I would favor the second approach. Have a read-only list of consultants. When the user wants to view or edit the assets for one of those, load the editable consultant object for that consultant and allow them to edit the asset assignments.

Christian

JCannelos replied on Monday, December 04, 2006

Thanks guys! Thats the way I'm going..

J'son

Copyright (c) Marimer LLC