Re: How to express this in objects?
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Sat, 16 Dec 2006 21:57:08 GMT
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
.
- References:
- How to express this in objects?
- From: Phil Wardie
- How to express this in objects?
- Prev by Date: Re: Isolatable Concerns
- Next by Date: Re: Transaction Oriented Architecture (TOA)
- Previous by thread: Re: How to express this in objects?
- Next by thread: Conference Announcement: Jan. 2007 in Munich, Germany
- Index(es):
Relevant Pages
|