|
Oi Aldo,
In my very humble (and beginner)
opinion, the singleton is an answer for the problem of having only one instance
of a class, very usefull for example, to instantiate a single application,
or maybe even to init a single facade of an
app.
There is an excelent article by Brendon O'Hara on
the CFDJ site explaining the Singleton Pattern: http://www.sys-con.com/coldfusion/article.cfm?id=624
The problem that I need to address is how to have a
repository of single objects, without having to go to the database to get them
everytime I need one,
and without having to instantiate them all when
initializing the app.
I got the solution from the source: Martin Fowler's
site has a very brief description for a patterm that does exactly what I need,
here is a quote from the site:
"Objects can be
added to and removed from the Repository, as they can from a simple collection
of objects, and the mapping code encapsulated by the Repository will carry out
the appropriate operations behind the scenes. Conceptually, a Repository
encapsulates the set of objects persisted in a data store and the operations
performed over them, providing a more object-oriented view of the persistence
layer."
It didn't surprised me that the Pattern is called
"Repository Pattern", here is the URL: http://www.martinfowler.com/eaaCatalog/repository.html
I also found the "Lazy Load" pattern, which will
help me on second part of the problem, that is not having to load all my objects
from the database when initializing the app, only when it's really needed for
the application.
I would love to see ColdFusion implementations of
both patterns, but since I didn�t find it, I will try to figure out by
myself.
Regards,
Marcantonio
Silva
|
- Re: [CFCDev] Shared persistent objects pattern ? Marcantonio Silva
- Re: [CFCDev] Shared persistent objects pattern ? Benjamin Pate
- RE: [CFCDev] Shared persistent objects pattern ? Micha Schopman
- Re: [CFCDev] Shared persistent objects pattern ... Marcantonio Silva
- Re: [CFCDev] Shared persistent objects patt... Marcos Placon�
- RE: [CFCDev] Shared persistent objects pattern ? SBarnes
