Re: Basic OO Question that I need to solve!
From: Guinness Mann (gmann_at_dublin.com)
Date: 03/11/04
- Next message: Daniel O'Connell [C# MVP]: "Re: Objects and code just disappearing!"
- Previous message: Jodie Rapson: "Re: What the......?"
- In reply to: fretts: "Basic OO Question that I need to solve!"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Daniel O'Connell [C# MVP]: "Re: Objects and code just disappearing!"
- Previous message: Jodie Rapson: "Re: What the......?"
- In reply to: fretts: "Basic OO Question that I need to solve!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|