Re: Business objects, subset of collection
- From: jimbalo22@xxxxxxxxx
- Date: Sun, 13 Jan 2008 12:04:40 -0800 (PST)
Lahman,
Thanks for the reply.
Example:
InvoiceCollection->Invoice->PaymentCollection->Payment
I assume this notation means something like:
[Customer]
| 1
|
| R1
|
| is billed with
| *
[Invoice]
+ date
| 1
|
| R2
|
| are paid by
| *
[Payments]
+ date
Almost. The application is for scheduling of payments of invoices and
what I posted was a simplfied version of this. Here is a more
accurate diagram:
[VendorCollection]
| 1
|
|
| *
[Vendor]
| 1
|
|
| 1
[InvoiceCollection]
| 1
|
|
| *
[Invoice]
| 1
|
|
| 1
[PaymentCollection]
| 1
|
|
| *
[Payment]
The answer definitely depends -- on what problems are being solved and
at what level of abstraction.
Here is a brief description of the app. It is a WinForm (C#) app
with:
* a Vendor grid bound to [VendorCollection], showing each [Vendor]
with amount due, payment total, etc.
* an Invoice grid bound to [InvoiceCollection], showing each [Invoice]
for the selected vendor
* a Payment grid bound to [PaymentCollection], showing each [Payment]
scheduled for the selected invoice.
The user needs to be able to view and work with a variety of filtered
subsets of the vendors / invoices:
1) The Vendor grid shows daily totals, monthly totals and grand totals
for each vendor.
2) The user can select one or more vendors in the vendor grid and
perform operations on all payments assigned to the invoices for those
vendors for the day (for example: remove payments, change payment
date, add payments).
3) The user can select one or more vendors in the vendor grid and
perform operations on all payments assigned to the invoices for those
vendors for the month.
4) The user can select one or more vendors in the vendor grid and
perform operations on all payments assigned to the invoices for those
vendors (no time-limiter)
5) The user can select one or more invoices in the invoice grid and
perform operations on all payments assigned to those invoices.
I have a Setfilter(DateTime filterDate) methods defined in the
classes, so that when you call SetFilter on for example
[VendorCollection], it in turns call SetFilter on each [Vendor] and so
forth.
The most general approach is (2) and most of the abstract action
languages (AALs) used in OOA/D will have a WHERE clause available for
any relationship navigation to filter the set of objects accessed. Thus
in an AAL method one might have something like
invoiceSet = this -> R1 WHERE (date=20080113)
FOREACH invoice IN invoiceSet
// process invoice objects
when the user wants invoices, or
paymentSet = this -> R1 -> R2 WHERE (date=20080113)
FOREACH payment IN paymentSet
// process payment objects
I am not familiar with Abstract Action Languages, but here is an
example of a method in [InvoiceCollection]:
public double PaymentTotalForDay
{
get
{
double amount = 0;
foreach (Vendor vendor in this)
amount += vendor.PaymentTotalForDay;
return amount;
}
}
This will return the total payment amount for the date specified in an
earlier call to Setfilter(filterDate). But since the VendorGrid also
needs to show PaymentTotalForMonth (regardless of day filtered on) and
PaymentTotal (no time-limiter), I wind up with two similar methods for
this. And then there are several other filter-specific methods, so it
does get a bit messy.
when the user wants payments. [Note that the WHERE clause filters theI belive I am doing something equivalent using the SetFilter method
date attribute in the target set. When a multistage path is navigated it
is assumed that the membership of the intermediate collections already
limits the set adequately. If not, one needs to do the second fragment
in two stages.]
above.
However, that is pretty much why collection classes exist; they manageI know, but I guess I was looking for a way to separate out all the
collections. More to the point, that is /all/ they do; they encapsulate
the collection management in one place. IOW, the collection class
isolates and encapsulates complexity of a highly focused nature. In
general that is a Good Thing. So there is nothing inherently wrong with
the second approach.
filter-specific responsibilities in such a way as to simplify and make
the design cleaner, but it seems that doing that just adds more
complexity.
Note that in the AAL, one just needs to substitute "amount<100" in theSince I am not familiar with AAL I do not quite follow this - is this
WHERE clause to deal with another selection criteria in the second
fragment above. The details of how one mucks about to extract that set
is left to the low level implementation so during OOA/D the application
developer doesn't need to think about it.
something I could use in my C# app as described above?
However, at OOP time one addresses other issues like performance andActually, Invoices are not added / removed, just paid. Payments are
maintainability. Suppose Invoices and Payments are very rarely added
what changes (=are modified, added & removed).
Thanks,
Jim
Ps. It is probably not relevant, but in the app I am using Rockford
Lhotka's CSLA framework.
.
- Follow-Ups:
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- References:
- Business objects, subset of collection
- From: jimbalo22
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Business objects, subset of collection
- Prev by Date: Re: Fundamental terms, question (Object Thinking)
- Next by Date: Re: Fundamental terms, question (Object Thinking)
- Previous by thread: Re: Business objects, subset of collection
- Next by thread: Re: Business objects, subset of collection
- Index(es):
Relevant Pages
|