Board index » delphi » TDataModule as parent class for Business Objects

TDataModule as parent class for Business Objects

I have seen a few examples where folks use TDatamodule as the parent object
of business objects. The datamodule is not autocreated. When building the
GUI, they put the unit name in the uses clause, and hook up the GUI data
aware controls to they descendant object, like TPerson. Next, there is a
private field on the GUI form like fPerson of type TPerson. When the GUI
form is created, in code the fPerson object is instantiated and the
databound controls are reset to use the new object by simply setting their
DataSource to fPerson.SomeDataSource. I can follow all of this no problem,
but I have also seen where after instantiation of fPerson, they immediately
set the name to '' or to some random string. I am not sure why. Does anyone
here have an explanation as to why this is needed when coding in this
fashion?

-Robbie

 

Re:TDataModule as parent class for Business Objects


Actually, I was refering the the sample code I have been viewing. It all
makes sense, with the exception of the assignment of a unuiqe name to the
instantiated datamodule.

-Robbie

Quote
"Kevin Frevert" <kfrev...@midwayusa.com> wrote in message

news:3ac097d0_2@dnews...
Quote
> By "they" you mean the databound controls losing their datasource
property?
> Are you using D3, D4, or D5?  I've ran into this many times using D4, but
> never using D5.

> krf

> newsgroups.borland.com <delphico...@hotmail.com> wrote in message
> news:3ac0868a_2@dnews...
> > I have seen a few examples where folks use TDatamodule as the parent
> object
> > of business objects. The datamodule is not autocreated. When building
the
> > GUI, they put the unit name in the uses clause, and hook up the GUI data
> > aware controls to they descendant object, like TPerson. Next, there is a
> > private field on the GUI form like fPerson of type TPerson. When the GUI
> > form is created, in code the fPerson object is instantiated and the
> > databound controls are reset to use the new object by simply setting
their
> > DataSource to fPerson.SomeDataSource. I can follow all of this no
problem,
> > but I have also seen where after instantiation of fPerson, they
> immediately
> > set the name to '' or to some random string. I am not sure why. Does
> anyone
> > here have an explanation as to why this is needed when coding in this
> > fashion?

> > -Robbie

Re:TDataModule as parent class for Business Objects


By "they" you mean the databound controls losing their datasource property?
Are you using D3, D4, or D5?  I've ran into this many times using D4, but
never using D5.

krf

Quote
newsgroups.borland.com <delphico...@hotmail.com> wrote in message

news:3ac0868a_2@dnews...
Quote
> I have seen a few examples where folks use TDatamodule as the parent
object
> of business objects. The datamodule is not autocreated. When building the
> GUI, they put the unit name in the uses clause, and hook up the GUI data
> aware controls to they descendant object, like TPerson. Next, there is a
> private field on the GUI form like fPerson of type TPerson. When the GUI
> form is created, in code the fPerson object is instantiated and the
> databound controls are reset to use the new object by simply setting their
> DataSource to fPerson.SomeDataSource. I can follow all of this no problem,
> but I have also seen where after instantiation of fPerson, they
immediately
> set the name to '' or to some random string. I am not sure why. Does
anyone
> here have an explanation as to why this is needed when coding in this
> fashion?

> -Robbie

Re:TDataModule as parent class for Business Objects


Quote
>with the exception of the assignment of a unuiqe name to the
>instantiated datamodule.

When you create a dm, it is added to the application's Screen.Datamodules
list.
The name of each list member must be unique.   Maybe that's what they are
trying
to accomplish.

=Bill

Other Threads