Re: Business objects, subset of collection



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 the
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.]
I belive I am doing something equivalent using the SetFilter method
above.


However, that is pretty much why collection classes exist; they manage
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.
I know, but I guess I was looking for a way to separate out all the
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 the
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.
Since I am not familiar with AAL I do not quite follow this - is this
something I could use in my C# app as described above?

However, at OOP time one addresses other issues like performance and
maintainability. Suppose Invoices and Payments are very rarely added
Actually, Invoices are not added / removed, just paid. Payments are
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.
.



Relevant Pages

  • Re: Help with query
    ... One suggestion would be to consider if you ever need to split a transaction, such as for two partial payments on one invoice or for one payment covering two invoices. ... FROM tblSalesOrder SO INNER JOIN (tblDespatch D INNER JOIN (tblTransaction T ...
    (microsoft.public.access.queries)
  • Re: A/R form creation?
    ... it is something like this month {i will work in month steps,but if a company has dept the amount will carry over to the nexxt month} the A company has purchased lets say 780USD, but in total i get paid for the amount of 500USD, the dept is 280USD and if in this month isn't paid it will start the new month with -280USD at their balance.... ... The absolute minimum is a new table for incoming payments, linked to Customers, and a union query to add amounts due and subtract amounts paid to calculate the outstanding balance. ... It would also help if you added an extra yes/no field to both tables to mark settled invoices and totally used-up payments so you exclude them from the union query, or it will introduce performance issues over time as the number of sales / payments increases. ... how you handle the settlement is a whole different ballgame! ...
    (microsoft.public.access.forms)
  • Re: Cant get query to work...
    ... I think I would start out with a query to sum payments against a specific ... INNER JOIN Invoices ON Orders.OrderID = Invoices.OrderID) ...
    (microsoft.public.access.queries)
  • Re: Business objects, subset of collection
    ... The invoices shown are for the selected vendor AND day. ... Vendor grid: Contains various levels of summary info for ALL invoices ... and scheduled payments for each vendor. ...
    (comp.object)
  • Re: Help with query
    ... expression in the summary subtracting payments from the invoice total.... ... I currently have the query for summing the total amount of Invoices each ... FROM tblSalesOrder SO INNER JOIN (tblDespatch D INNER JOIN (tblTransaction T ... The problem here is a Transaction can be for more than one invoice.. ...
    (microsoft.public.access.queries)