Re: How to express this in objects?



Responding to Wardie...

Hello,

I'm looking for a nice/elegant object structure to be able to do express the following:

- Per project there are multiple project expenses (expense properties: description, amount and price).

- It is possible that a single expense is split over multiple projects. I need to store the amount and price per project, but also need a reference to an object that contains the total amount and price (maybe calculated based on the "child" expense objects)

As McGill suggests, I think you need to separate the notion of overall expense from project expense.

[Project]
| 1
|
| R1
|
| accrues
| *
[ProjectExpense]
+ amount
| *
| accumulates
|
| R2
|
| 1
[OverallExpense]
+ description
+ price

The interesting question is whether one needs a totalAmount attribute in [OverallExpense]. Technically that would create a problem because the value of the attribute depends upon the values of ProjectExpense.amount in the R2 relationship set. That would violate 3rd Normal Form because the value does not depend solely on the identity of the OverallExpense object. IOW, a purist would compute the value by "walking" the R2 collection whenever asked.

However, as a practical matter it is fairly common to deliberately denormalize in such situations (e.g., to improve performance). (DBAs do similar things with telephone numbers and whatnot in RDBs.) In UML the convention is to identify such dependencies with a derived attribute marker (a preceding "/"):

[OverallExpense]
+ description
+ price
+/ totalAmount

The presence of the marker indicates a constraint must be defined for the dependency (in this case through the R2 relationship). One would then have to supply an OCL constraint, abstract action language, or some other description to ensure the constraint was defined.


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH



.



Relevant Pages

  • Re: Fao: Laptop Aries
    ... >> But the Medion PC (such as the ones that ALDI do) aren't expensive! ... > his car, servicing, etc etc. and I don't have a car of my own any ... expense of the car. ... >> Price that you see on the Website isn't the Price that you actually ...
    (uk.people.silversurfers)
  • How to express this in objects?
    ... Per project there are multiple project expenses (expense properties: description, amount and price). ...
    (comp.object)
  • Re: Quo Computer
    ... Rotten Apple wrote: ... Some people will always want cheaper, even at the expense of other ... Steve Jobs got that jet by making suckers like you pay four times the price of a PC to have a Mac! ...
    (comp.sys.mac.advocacy)
  • Re: How to express this in objects?
    ... Per project there are multiple project expenses (expense properties: ... description, amount and price). ... It is possible that a single expense is split over multiple projects. ...
    (comp.object)
  • Re: Any tips for UK Train Travel for a first time American?
    ... I wouldn't argue very hard if you just said it was the most ... unfavourably to the railways of Germany, ... tourisme at the expense of the continent's many social democracies. ... I'm more concerned about the high price of urban and local transit ...
    (rec.travel.europe)