 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ross Guest
|
Posted: Fri Oct 24, 2003 12:35 pm Post subject: TClientDataset Approach |
|
|
Are there any good simple examples or articles on using a TClientDataset
in OOP? I have tried a few different approaches and have not quite come
up with one that is where I want it. Just wondering if someone has
documented a different approach.
What I am trying to figure out is where does the TClientDataset reside.
I have a very simple BO
TPerson = Class
Private
FFirstName : string;
FLastName : string;
FMiddleInitial : string;
FBirthDate : string;
FAge : integer;
Public
constructor Create;
destructor Destroy;override;
property FirstName : string read FFirstName write FFirstName;
property LastName : string read FLastName write FLastName;
property MiddleInitial : string read FMiddleInitial write
FMiddleInitial;
property BirthDate : string read FBirthDate write FBirthDate;
property Age : string read FAge write FAge;
end;
At first I placed that TClientdataset as a property of this class, and
had it working with data in a grid. But this did not really sit right
with me.So, then I tried using a Clientdataset along side the class but
that seemed self defeating. So I assume I need to make a TPersonList
class and make the TClientDataSet a property of that class? That
TPersonList class would talk to a data class of some sort to provide
data and flush updates for it.
I know others will say dump the TClientDataset but I am unwilling/unable
to do so per other constraints. I would really like to find a middle
ground here somewhere.
Thanks for the help,
Ross
|
|
| Back to top |
|
 |
Joanna Carter Guest
|
Posted: Fri Oct 24, 2003 1:31 pm Post subject: Re: TClientDataset Approach |
|
|
Ross wrote:
| Quote: | Are there any good simple examples or articles on using a
TClientDataset in OOP? I have tried a few different approaches and
have not quite come up with one that is where I want it. Just
wondering if someone has documented a different approach.
|
The idea behind using a TClientDataset is to allow the use of data-aware
controls with business objects. The BOs should not know anything about the
CDS, but you need to derive from the CDS to provide a mechanism for
populating the CDS from the BO or a list of BOs.
The CDS sits between the BO and its controls on a form. Do you have a means
of examining the metadata of your BOs so you can fill up the CDS?
Joanna
--
Joanna Carter
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Ross Guest
|
Posted: Fri Oct 24, 2003 1:41 pm Post subject: Re: TClientDataset Approach |
|
|
Joanna Carter wrote:
| Quote: | Ross wrote:
| Are there any good simple examples or articles on using a
| TClientDataset in OOP? I have tried a few different approaches and
| have not quite come up with one that is where I want it. Just
| wondering if someone has documented a different approach.
The idea behind using a TClientDataset is to allow the use of data-aware
controls with business objects. The BOs should not know anything about the
CDS, but you need to derive from the CDS to provide a mechanism for
populating the CDS from the BO or a list of BOs.
The CDS sits between the BO and its controls on a form. Do you have a means
of examining the metadata of your BOs so you can fill up the CDS?
|
Ok. This is what I was thinking along.
I was just starting to read on the RTTI so I can fill the CDS with
fields and not have to hard code it. but if it was hard coded that would
not be the end of the world, make maintenance more difficult though.
Ross
|
|
| Back to top |
|
 |
Brad White Guest
|
Posted: Fri Oct 24, 2003 5:14 pm Post subject: Re: TClientDataset Approach |
|
|
"Ross" <polks71 (AT) hotmail (DOT) com> wrote
| Quote: | Are there any good simple examples or articles on using a TClientDataset
in OOP? I have tried a few different approaches and have not quite come
up with one that is where I want it. Just wondering if someone has
documented a different approach.
What I am trying to figure out is where does the TClientDataset reside.
I have a very simple BO
TPerson = Class
snip
At first I placed that TClientdataset as a property of this class, and
had it working with data in a grid. But this did not really sit right
with me.So, then I tried using a Clientdataset along side the class but
that seemed self defeating. So I assume I need to make a TPersonList
class and make the TClientDataSet a property of that class? That
TPersonList class would talk to a data class of some sort to provide
data and flush updates for it.
|
Ross,
Good question.
General speaking, a TPerson does not correspond to a list
of items, rather it is an item in the list.
So you need to have a List of TPersons.
It could either own and manage the Persons in the list, or
it could just track, depending on your needs.
Depending on where your data is coming from, and which
direction it is flowing, your CDS could be either above or
below TPerson. In other words, it could either feed data
to the Persons, or vice-versa.
What I really like is the ability to descend from the CDS
to create an intelligent list that handles talking to the Person
objects.
--
Thanks,
Brad White
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Fri Oct 24, 2003 11:09 pm Post subject: Re: TClientDataset Approach |
|
|
Ross wrote:
| Quote: | Are there any good simple examples or articles on using a
TClientDataset in OOP? I have tried a few different approaches and
have not quite come up with one that is where I want it. Just
wondering if someone has documented a different approach.
What I am trying to figure out is where does the TClientDataset
reside.
|
I would not make the CDs a property of the BO but would do the following:
A separate class to create and return the CDS, passed a target BO List.
- this removes knowledge of datasets from the BO list objects and thus
allows any type of memory dataset to be used
- the separate class could be a descendant of a dataset itself, but I tend
to want to keep those free of BO knowledge as well - concentrating that
knowledge only in a class whose purpose is to perform transfers between
datasets and BOs.
I was intending to write an article / sample code on this very thing in time
for the conference but unfortunately that hasn't happened. I will try to do
so in the near future though.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
|
|
| Back to top |
|
 |
John Small Guest
|
Posted: Sat Nov 01, 2003 2:07 pm Post subject: Re: TClientDataset Approach |
|
|
We've all had much the same problem and I was about to role up my sleeves
and go to work on a new implementation of the wheel when I discovered that
the latest version of Developer Express Quantum Grid allows you to use BO's
as providers for their grids. So I tried it out and it's quite nifty,
though it's a shame that the same idea hasn't been propagated to their other
controls. What I like about it as compared with the
BO<->TClientDataset<->dbAwareGrid is that the fiddly business of getting
updates/inserts/deletes on the TClientDataset into the BO can be avoided.
I've now got a simple descendant of their customSource that knows how to
work with my BO's, it's quite brill!
John Small
"Ross" <polks71 (AT) hotmail (DOT) com> wrote
| Quote: | Are there any good simple examples or articles on using a TClientDataset
in OOP? I have tried a few different approaches and have not quite come
up with one that is where I want it. Just wondering if someone has
documented a different approach.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|