|
-
Implementing relational concepts the OOP way
Most of my IT experience is developing and programming relational databases
based apps. So I'm trying to implements some of the things I find with rel.
dbs in OOP using VB6. Here are some of my thoughts:
1. Save and retrieval of objects:
Saving and retrieval of objects (let's say Customer object), is trivial,
I just implement Save method which does some kind of state management to
determine whether to save to update to the database. For retrieval, I do
the same, my Retrieve method receives an primary key parameter to know what
to look for in the database.
However, and I would appreciate your opinion here, if I'm going to implement
things like Queries or the functionality of doing, movefirst, movelast etc.
Then my Customer object is not enought. What I'm doing is to implement another
type of object, like a CustomerList that handles only Customer Code and Description
and allows to navigate through the objects, when the user decides that he
wants to work with a specific Customer, then it creates a Customer object
doing the retrieval by the PK. (I think I read somewhere that this is the
idea of the Proxy design pattern).
2. Validating foreign keys,
This is the one that has me really puzzled!, Let's say I'm creating a Customer
and one of the properties is the Salesperson that manage that account, how
do I go about validating the foreign key?, should I try to retrieve a Salesperson
object and if it fails then it means that is not valid?, what if Salesperson
is a rather complex object, isn't it a waste to load it in memory?, should
I load a proxy object as well?
Well, I'd like to get your opinion on this, and sorry for the lengthy message.
Thanks,
Vicente.
-
Re: Implementing relational concepts the OOP way
Hi Vicente -
With regard to #1, the way that we do our Customer objects is to provide
a Retrieve method with a parameter that identifies a retrieve type. The Retrieve
method can then retrieve either the list of customer key information (for
a list of some type) or a particular customer record.
With regard to #2, we do this several different ways, depending on the requirements
of the project. One way is to identify a retrieve method that retrieves subobjects.
So if you retrieve with the subobject it will retrieve the associated information.
An alternative is to use separate objects. We would do a Customer object
and a SalesPerson object. Then we would implement a Controller class (Mediator
design pattern) that manages the relationship between the customer and the
salesperson.
Good luck!
Deborah
"Vicho" <vmbarreiro@earthlink.net> wrote:
>
>Most of my IT experience is developing and programming relational databases
>based apps. So I'm trying to implements some of the things I find with rel.
>dbs in OOP using VB6. Here are some of my thoughts:
>
>1. Save and retrieval of objects:
>Saving and retrieval of objects (let's say Customer object), is trivial,
>I just implement Save method which does some kind of state management to
>determine whether to save to update to the database. For retrieval, I do
>the same, my Retrieve method receives an primary key parameter to know what
>to look for in the database.
>However, and I would appreciate your opinion here, if I'm going to implement
>things like Queries or the functionality of doing, movefirst, movelast etc.
>Then my Customer object is not enought. What I'm doing is to implement another
>type of object, like a CustomerList that handles only Customer Code and
Description
>and allows to navigate through the objects, when the user decides that he
>wants to work with a specific Customer, then it creates a Customer object
>doing the retrieval by the PK. (I think I read somewhere that this is the
>idea of the Proxy design pattern).
>
>
>2. Validating foreign keys,
>This is the one that has me really puzzled!, Let's say I'm creating a Customer
>and one of the properties is the Salesperson that manage that account, how
>do I go about validating the foreign key?, should I try to retrieve a Salesperson
>object and if it fails then it means that is not valid?, what if Salesperson
>is a rather complex object, isn't it a waste to load it in memory?, should
>I load a proxy object as well?
>
>Well, I'd like to get your opinion on this, and sorry for the lengthy message.
>
>Thanks,
>
>Vicente.
Similar Threads
-
By Mark Jerde in forum .NET
Replies: 146
Last Post: 08-18-2002, 04:41 AM
-
By Randy Charles Morin in forum Architecture and Design
Replies: 42
Last Post: 01-03-2002, 06:22 AM
-
By Joe \Nuke Me Xemu\ Foster in forum Architecture and Design
Replies: 2
Last Post: 06-11-2001, 04:05 AM
-
By Randy Charles Morin in forum Architecture and Design
Replies: 0
Last Post: 05-16-2001, 01:46 AM
-
By rmorin@kbcafe.com in forum Enterprise
Replies: 0
Last Post: 03-07-2001, 12:45 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks