aggregate boundries
- From: "kurbylogic@xxxxxxxxxxx" <kurbylogic@xxxxxxxxxxx>
- Date: 29 Jan 2006 13:38:29 -0800
I'm attempting to create a program to help me budget my money. I
want to do something different form money/quicken in that I assign my
existing assets to categories such as mortgage and savings each expense
will then be deducted from the category and credited by my paychecks
allowing me to more easily determine how much money I have set aside
for the category. But I'm having a bit of trouble determining how
to maintain the relationship invariants in OO.
Account, Category, and Payee are root objects
Category is a composite containing other Categories
Account owns Transactions and Transaction owns TransactionCategory
The invariants are that Transaction.Payee is member of Payees and
TransactionCategory.Category is member of Categories
I've created a larger aggregate DataContext to encapsulate the list
of accounts, payees and root categories. I use an identity map during
load to ensure the correct instances are assigned to each object. The
model is not bi-directional so if I ask for all transactions by
category I search every transactioncategory of every transaction in
every account. My primary view will be by category so I think a
bi-directional relation here might be best but at the moment category
knows nothing about transaction, and I've optimized the search a bit
by assigning left/right tree numbers to each category. The question I
have is what the best way to control modifications is. My first
thought was that when context is saved my thinking was I would
enumerate all transactions in the datacontext if no id is assigned its
new, if transaction.HasChanges I update and if the transaction was
loaded but is no longer in the transaction collection it was deleted,
and likewise for each payee, category, and transaction.
The problem is that this doesn't ensure the invariants above are not
violated, context.getAccounts()[0].getTransactions()[0].Payee = new
Payee("Test"); and similarly in relation to categories. I don't
want to reload the data on every change and in some cases is not
possible as I'm also performing updates via an Indigo service to
allow me to access my info from home or work but at some clients I'm
not allowed to connect my laptop to the network and so I wanted to be
able to save a serialized copy of the datacontext to disk and queue
modifications so that they can be sent later when connection is
available.
In theory every change should be done through the data context, but
I'm not sure the best way to enforce this. Generally speaking, I
would make the object immutable or clone the object when added to an
aggregate so the client couldn't make any unauthorized modifications.
Account name, payee name and category path could be used as qualifiers
for those objects perhaps however transaction does not have any
uniquely identifying property I could use as a qualifier and thus
cloning the object would change its identity. Additionally I don't
really want to be making deep copies of the account and all its
transactions. How else might I go about this?
Thanks,
- Kurt
.
- Follow-Ups:
- Re: aggregate boundries
- From: H. S. Lahman
- Re: aggregate boundries
- Prev by Date: Re: SQL
- Next by Date: Re: SQL
- Previous by thread: slightly OT: pronounciation
- Next by thread: Re: aggregate boundries
- Index(es):
Relevant Pages
|