BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Object liberation and persistence layers

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Gabriel GIbaut
Guest





PostPosted: Mon Jan 17, 2005 6:59 pm    Post subject: Object liberation and persistence layers Reply with quote



Hello,

I need some pointers about persistence layers.

All the information i´ve found is about mapping, cacheing and persisting
objects to the database. But what about freeing the objects? Who is
responsible for this? (The programmer?)What if you have a cache? (is the
persistence layer responsible then?) Are there well known strategies to
deal with this subject?

Any info on persistence layers would be appreciated.

Gabriel


Back to top
Jim Cooper
Guest





PostPosted: Mon Jan 17, 2005 7:17 pm    Post subject: Re: Object liberation and persistence layers Reply with quote



Quote:
But what about freeing the objects? Who is
responsible for this? (The programmer?)

In Win32. In .NET you can let the GC take care of it.

Quote:
What if you have a cache? (is the
persistence layer responsible then?)

Yes, but you need to track usage somehow still in Win32. in .NET you may
have the opposite problem, in that you need to keep a reference alive to
all objects in the cache, or they'll disappear occasionally :-)

Cheers,
Jim Cooper

_______________________________________________

Jim Cooper [email]jim (AT) falafelsoft (DOT) com[/email]
Falafel Software http://www.falafelsoft.com
_______________________________________________

Back to top
Gabriel GIbaut
Guest





PostPosted: Mon Jan 17, 2005 7:20 pm    Post subject: Re: Object liberation and persistence layers Reply with quote



I forgot to mention, i´m working with D7

Thanks

Gabriel

"Jim Cooper" <jim (AT) falafelsoft (DOT) com> escribió en el mensaje
news:41ec0f64$1 (AT) newsgroups (DOT) borland.com...
Quote:
But what about freeing the objects? Who is
responsible for this? (The programmer?)

In Win32. In .NET you can let the GC take care of it.

What if you have a cache? (is the
persistence layer responsible then?)

Yes, but you need to track usage somehow still in Win32. in .NET you may
have the opposite problem, in that you need to keep a reference alive to
all objects in the cache, or they'll disappear occasionally :-)

Cheers,
Jim Cooper

_______________________________________________

Jim Cooper [email]jim (AT) falafelsoft (DOT) com[/email]
Falafel Software http://www.falafelsoft.com
_______________________________________________



Back to top
Marc Rohloff [TeamB]
Guest





PostPosted: Mon Jan 17, 2005 8:53 pm    Post subject: Re: Object liberation and persistence layers Reply with quote

On Mon, 17 Jan 2005 15:59:52 -0300, Gabriel GIbaut wrote:

Quote:
But what about freeing the objects? Who is
responsible for this? (The programmer?)What if you have a cache? (is the
persistence layer responsible then?) Are there well known strategies to
deal with this subject?

This is the advantage of interfaces since they are reference counted
they handle this more or less automatically.

--
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Mon Jan 17, 2005 9:07 pm    Post subject: Re: Object liberation and persistence layers Reply with quote

Bold always references objects via an ObjectLocator. If you ask for an
object the locator will load it. Each time you read/write an attribute /
association of the object an internal "last touched" datetime stamp is
updated for the object.

You can then have an object unloader component. Tell it to run every 5
minutes, unloading any objects which haven't been touched for 15 minutes
(for example).


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


Back to top
Jim Cooper
Guest





PostPosted: Mon Jan 17, 2005 9:50 pm    Post subject: Re: Object liberation and persistence layers Reply with quote


Quote:
I forgot to mention, i´m working with D7

OK. Then see Marc's and Peter's replies for some different strategies.

Cheers,
Jim Cooper

_______________________________________________

Jim Cooper [email]jim (AT) falafelsoft (DOT) com[/email]
Falafel Software http://www.falafelsoft.com
_______________________________________________

Back to top
Bob Dawson
Guest





PostPosted: Tue Jan 18, 2005 1:08 am    Post subject: Re: Object liberation and persistence layers Reply with quote

"Gabriel GIbaut" wrote

Quote:
objects to the database. But what about freeing the objects? Who is
responsible for this? (The programmer?)What if you have a cache? (is the
persistence layer responsible then?) Are there well known strategies to
deal with this subject?

There are several approaches. I do use a cache so I'll describe that
briefly. Basically the object service layer maintains a ref-counted list of
all active business objects. When an application programmer requests an
object
myObj := TSomeBizObject.BOCreate(14); //a class function, not a
constructor
what happens is
the class function forwards the request to the object service layer
that layer searches the active objects list by class and instance ID to see
if the object already exists in memory. If it does, a reference is returned
and the refcount incremented.
if not, the request is forwarded to the data service layer, which searches
all current datasets in memory to see if the object can be instantiated
based on current information. If so, this is done, the object is entered
into the active objects list, which returns a reference to this object as
before
if not, the request is forwarded to the persistence layer and an SQL call
is issued to retrieve the object's information. The object is then built
from this dataset (which is then discarded) and then returned as before.
The the programmer releases the object this call is also fowarded to the
object service layer active object list, which decriments the refcount and
decides whether to free the object accordingly.

Quote:
Any info on persistence layers would be appreciated.

Here are some starting places:

Brown, Philip. "An Object Oriented Persistence Layer Design." Philip
published a series of introductory articles in the late EXE magazine (UK).
These are available from the Borland Community CodeCentral website, in the
category "Best Techniques / Delphi", submission #15511.

Ambler, Scott. http://www.ambysoft.com/ Has many interesting pieces in the
online white papers section, including a paper containing a general class
model for a complete persistence layer: "Design of a Robust Persistence
Layer for Relational Databases."

Carter, Joanna. http://www.carterconsulting.org.uk See her four-part
"Keeping Hold of Your Things" article, and the link to "A Series of Articles
on Object Persistence."

Fowler, Martin. http://www.martinfowler.com/. From his main site, use the
"Articles" link at the top of the page. From the articles page see the
pieces "Separating User Interface Code" and "Reducing Coupling."

bobD



Back to top
Gabriel GIbaut
Guest





PostPosted: Wed Jan 19, 2005 6:54 pm    Post subject: Re: Object liberation and persistence layers Reply with quote

Thanks eveyone for their response.

Gabriel


"Bob Dawson" <RBDawson (AT) prodigy (DOT) net> escribió en el mensaje
news:41ec68c4 (AT) newsgroups (DOT) borland.com...
Quote:
"Gabriel GIbaut" wrote

objects to the database. But what about freeing the objects? Who is
responsible for this? (The programmer?)What if you have a cache? (is the
persistence layer responsible then?) Are there well known strategies to
deal with this subject?

There are several approaches. I do use a cache so I'll describe that
briefly. Basically the object service layer maintains a ref-counted list
of
all active business objects. When an application programmer requests an
object
myObj := TSomeBizObject.BOCreate(14); //a class function, not a
constructor
what happens is
the class function forwards the request to the object service layer
that layer searches the active objects list by class and instance ID to
see
if the object already exists in memory. If it does, a reference is
returned
and the refcount incremented.
if not, the request is forwarded to the data service layer, which
searches
all current datasets in memory to see if the object can be instantiated
based on current information. If so, this is done, the object is entered
into the active objects list, which returns a reference to this object as
before
if not, the request is forwarded to the persistence layer and an SQL call
is issued to retrieve the object's information. The object is then built
from this dataset (which is then discarded) and then returned as before.
The the programmer releases the object this call is also fowarded to the
object service layer active object list, which decriments the refcount and
decides whether to free the object accordingly.

Any info on persistence layers would be appreciated.

Here are some starting places:

Brown, Philip. "An Object Oriented Persistence Layer Design." Philip
published a series of introductory articles in the late EXE magazine (UK).
These are available from the Borland Community CodeCentral website, in the
category "Best Techniques / Delphi", submission #15511.

Ambler, Scott. http://www.ambysoft.com/ Has many interesting pieces in the
online white papers section, including a paper containing a general class
model for a complete persistence layer: "Design of a Robust Persistence
Layer for Relational Databases."

Carter, Joanna. http://www.carterconsulting.org.uk See her four-part
"Keeping Hold of Your Things" article, and the link to "A Series of
Articles
on Object Persistence."

Fowler, Martin. http://www.martinfowler.com/. From his main site, use the
"Articles" link at the top of the page. From the articles page see the
pieces "Separating User Interface Code" and "Reducing Coupling."

bobD





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.