Re: Basic OO Question that I need to solve!

From: Guinness Mann (gmann_at_dublin.com)
Date: 03/11/04


Date: Wed, 10 Mar 2004 17:56:08 -0700

On Mon, 08 Mar 2004 22:39:41 GMT, fretts <fretts4@hotmail.com> wrote:

>==== Simplified example:
>If we have a concept of customers, and that each customer has one or
>many jobs (projects we carry out for them), it would seem sensible to
>have a "Company" class and a "Job" class.
>====
>==== My best guess
>I am guessing that each of these classes would have a "Load" method
>that would tload the given Company/Job data from the database, either
>called by the constructor or a separate call.
>
>At some point we are going to want to access a list of all jobs for a
>given customer. My first stab at this would be to create :
>
>Customer.GetLiveJobs();
>
>My question is, should this return a dataset or a collection of job
>objects?.

Personally, when I instantiated the Customer, in the constructor, I
would get a list of jobs for the customer and work my way through the
recordset, instantiating job objects for each one. Because I don't
like to mix database code in with the application (It makes it too
hard for the maintenance programmer -- he's got to understand too much
technology at once), I would store the job objects in a container of
some sort, and provide a property for retrieving the container.

>What about ASP .NET pages that want to use the same technology, they
>usually deal in XML or datasets not collections of objects right?

Only if they don't have a background in OO. (Remember, an awful lot
of ASP.NET developers were vb-script (ASP) developers last week.)

One consideration with the ASP-side is that if you have to save
hundreds of K of state information (all those job objects, maybe), it
might be more efficient overall to get a record when you need one.

I'd still abstract out the database aspects and provide a library that
had methods like getJobsForCustomerId(cId) vs getDataReaderForJobDb().

I have a program that I implemented in both Windows Forms and as a Web
project. I used the same back-end for both. In the Windows Forms
program the customer.getNextJob() method serves the job objects out of
an ArrayList. In the Web version, so that I don't have to save that
ArrayList between roundtrips, the customer.getNextJob function makes a
call to the database...

-- Rick



Relevant Pages

  • Re: Is this possible???
    ... I need to generate service reports ... >Customer ID, Week of Service, Type of Service ... Access is a relational database. ... Forms are just windows that allow you to enter data into the Tables; ...
    (microsoft.public.access.formscoding)
  • Re: 10g Database Configuration Assistant fails with code ORA-12546
    ... > Wes Harrison wrote: ... >>>check Generate Database Creation Scripts. ... >> something to do with the way Oracle interacts with Windows Server 2003 ... The "customer" is my boss who has this machine to run his SMB ...
    (comp.databases.oracle.server)
  • Re: Stopping access to database outside application
    ... Windows Authentication mode. ... You're granted access to the database by ... user can view all the customer but can't modify or add new one. ... but what if you have a creative user that somehow has ...
    (microsoft.public.sqlserver.security)
  • Spreadsheet/VBA Project Consulting: 50% Discount or Even Free - Limited Time Only
    ... UDQ Consulting Services Believes that Every Problem Should Have an Easy & ... templates, spreadsheet applications, and database applications. ... P001: Mortgage Transaction Spreadsheet Database ... Customer List Converted from Excel Table to Word ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Spreadsheet/VBA Project Consulting: 50% Discount or Even Free - Limited Time Only
    ... > UDQ Services has years of experience with MS Excel and VBA (Visual Basic ... > templates, spreadsheet applications, and database applications. ... > P001: Mortgage Transaction Spreadsheet Database ... Customer List Converted from Excel Table to Word ...
    (microsoft.public.excel.worksheet.functions)