By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

Re: Object modeling question

P: n/a


siddharthkh...@hotmail.com wrote:
Hi,
I have three main entities in system ............... report ,
sections , lineItem.
Requirements :
a section can be create by assembling some line items together.

a report can be created by assembling some sections together.

A administrator will have functionality to delete or add to a master
list of sections and attributes.
so in other word there are delete and add operations happening on
sections and line items out side of a context of specific report.

OK to model this....
i will have a report object. That will hold a collections of sections
and each individual section will hold collection of line items.

Something like this...
Report.Sections[i].lineItems[j].LineItemName
Now lets assume that there are two types of consumers that will using
this object model. A web applications, A windows think client
application
Good luck. The behavior and conventions of web versus fat-client (or
paper-oriented) reports are so different that making a generic
anything that serves both of them without rewrite is a big challenge
unless you pick a lowest common denominator, which limits things.
>
------------------------------------------------------------------------------------------
what I am trying to find out by this questions and discussion
is ..What is the best way to model this and how your object model will
change when you move from web app to windows app.

Let's take example of web application ....

Use case is delete first line item that is with in first section and
sections is inside a specific report object..

so code in my web page will look like this...
Report.Section[0].LineItem[0].Delete();

But this a web app. in most cases you will not keep your report object
on postbacks. And obviously for performance reason you are not going
to re-create the full report object again on post back and then call
delete on that ...so here is my first question..

Where would you put the method to delete the line item from report?

Would you put it as an instance method directly on report object..as
shwon below?

Report.DeleteLineItem(SectionID,LineITemId)

If yes......

But another consumer form my object model is a windows app ...where It
may be ok to keep object in memory unlike web app.
so this call may be fine as i have a fully loaded report object in
memory.
Report.Section[0].LineItem[0].Delete();

so how would you come up with common object model that works for
both ...it is possible without writing more service layers?

--------------------------------------------------------------------------

Another use case....

Sections and line items can be deleted in the context of a report as i
described above
OR they can be deleted system wide by administrators .so if a section
or line item is not in use by any report presently admin can delete
them from the master list.

now question is what is the best place to put these delete method....

if i put them in the same sections and line items objects that I used
above
then i can write code like this....

LineItems.LoadAll()
LineItems[0].DeleteSystemWide()
but down side of this is ....they will be available in this call as
well...

Report.Section[0].LineItem[0].DeleteFromSystem();
This does not make sense because i am trying to delete system wide but
calling it on a specific report object....

So what are the solutions....

Should i use explicit interface implementation (c#)?
shoud i create separate classes and put them in separate name
spaces ..like admin.LineItem will have system wide delete function but
other line item class will not......this also is ugly because i am
creating two classes for same entity only because of this one
behavior.....
Any ideas and other ways to do it..?
If you have more than about 50 and they will be changing often by
different people, consider tracking report configuration settings in a
database.

A "toy" example that sort of illustrates this can be found at:

http://www.geocities.com/tablizer/chal06.htm
>
Thanks
Siddharth
-T-
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.