>I have a customer table made up of customers of at least 2 different types. I create three classes: BaseCust, Cust1, and Cust2. For the sake of illustration the method FigureAmtDue is completely different for Cust1 and Cust2. I understand how this works in plain jane code: Create an instance of whichever class you are working with and call the method. However, how is this done on a report where I am trying to figure the total amount due for all customers? Do I create an instance of the class on the record break and subsequently destroy it only to call it again? I must be missing something in my understanding of Classes or is this the way it is actually done? I guess the same thing would apply on a grid if there is a calculated field. Someone please help me before I completely screw up a project. Thanks :)
That's the classic "impedance" problem; the different points of view needed for DB work or OO work. Working purely in an OO way, you would have two "collections", one for each kind of customer: ACustomersCollection and BCustomersCollection. You would go through each object ("A" type customer) in the first collection, calculate its amount due, and print it; then you would go through each object ("B" type customer) in the second collection, and repeat the process.
Working with DB's, I don't see easy ways to do that; my first solution would involve having a field CUSTOMER_TYPE, and writing something like IIF(CUSTOMER_TYPE="A", FigureAmtDueForACust(), FigureAmtDueForBCust()).
I think there is another possibility: you could have a procedure which, given a Customer Id, returns an object of the correct class; then you could print FindTheCustomer(CustomerId).FigureAmtDue().
This kind of problem (trying to join (no pun intended) the DB oriented view and the OO way of working) is what I'm working on, so I would also gladly hear opinions on the solutions.
HTH!
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only