I have two doubts hitting my mind:
1) What is the best way to populate foreign keys into a bean?
Supposing I have a class Product.
Each product has a Category.
What is the right way:
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( 1 );
or
beanCategory = serviceCategory.getBean( 1 );
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( beanCatebory );
or neither?
2) In CF community we use to talk about DAOs and Gateways but it doesn't
seem a widely used pattern.
What is the best usage? Have just one DAO as Row Data Gateway and
Table Data Gateway or use DAO as RDG and Gateways as TDG?
Thanks,
Ronan
Hi,
I have two doubts hitting my mind:
1) What is the best way to populate foreign keys into a bean?
Supposing I have a class Product.
Each product has a Category.
What is the right way:
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( 1 );
or
beanCategory = serviceCategory.getBean( 1 );
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( beanCatebory );
or neither?
2) In CF community we use to talk about DAOs and Gateways but it doesn't
seem a widely used pattern.
What is the best usage? Have just one DAO as Row Data Gateway and
Table Data Gateway or use DAO as RDG and Gateways as TDG?
Thanks,
Ronan
So following the 'encapsulate what varies' idea I keep them separate.
Alan
________________________________________
From: cfc...@googlegroups.com [cfc...@googlegroups.com] On Behalf Of Brian Kotek [bria...@gmail.com]
Sent: 20 June 2008 22:06
To: cfc...@googlegroups.com
Subject: [CFCDEV] Re: Doubts about Best Practices
This is the key issue I tried to raise in my design patterns talk at
MAX last year (there's a recording on UGTV of the preso I gave later
to IECFUG I think).
So much of the patterns talk shows pattern + code instead of pattern +
tradeoffs which is by far the more important aspect of patterns.
> unfortunate reality is that truly groking OOP takes a long time and a major
> shift in mindset. There's no easy route to getting there, but one route that
Agreed. But when I tell people that, sometimes they react badly
thinking I'm being elitist or implying they are "too stupid" to learn
OO. The reality is: it's hard. I started learning OO in '92 and my
first few years worth of code was embarrassing. Fast forward 16 years
and I'm still learning and shifting my focus on OO issues.
One of the key lines in Hal's preso was "forget the database" and if
you want to design a reasonable OO system, you really do have to try
to do that. Clearly, if you have a very data-centric app with almost
no "behavior" (i.e., it's almost pure data entry or pure reporting)
then OO might be a waste of time for you - or maybe only parts of the
app will benefit from OO, perhaps at a very high level in the service
layer.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
Maybe it's time (finally) for OOBDMSs to come back into favor? :)
OODBMS. *ahem*
I may be somewhat naive in what type of apps people are building, but
I would guess that a good majority of apps can really be described as
data centric. Any e-commerce site is basically that. Any customer
management app is basically data centric. Calendars & events - data.
While I know blindly running with the 5-1 cfc is not a good way to
learn OO, I have found that the DAO / Gateway works and does make app
maintenance easier. Encapsulating the CRUD and other "aggregate"
selects makes the queries much easier to reuse. As does having a
service layer that provides an API to get to those queries.
Yes, we shouldn't argue about if the DAO & Gateway should be one CFC
or not; that is more of a personal preference. But I don't think we
should dismiss the usefulness of this for these "data centric" apps,
which seem to be quite common.
--
Matt Williams
"It's the question that drives us."
I may be somewhat naive in what type of apps people are building, but
I would guess that a good majority of apps can really be described as
data centric. Any e-commerce site is basically that. Any customer
management app is basically data centric. Calendars & events - data.
Hi,
I have two doubts hitting my mind:
1) What is the best way to populate foreign keys into a bean?
Supposing I have a class Product.
Each product has a Category.
What is the right way:
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( 1 );
or
beanCategory = serviceCategory.getBean( 1 );
beanProduct = serviceProduct.getBean();
beanProduct.setName( "It's name" );
beanProduct.setCategory( beanCatebory );
or neither?
2) In CF community we use to talk about DAOs and Gateways but it doesn't
seem a widely used pattern.
What is the best usage? Have just one DAO as Row Data Gateway and
Table Data Gateway or use DAO as RDG and Gateways as TDG?
Thanks,
Ronan
This is the piece I told Hal at dinner I thought he missed. Code generators and ORMs are probably a philosophically poor solution to a problem since they do tend to create very data-centric models but they are a solution nonetheless. So, when you get all the Acme Corps on OODMS's, then I might reevaluate :)
Agreed. I'm in an environment where I can still design and build a
decent OO model but have a seasoned DBA construct the schema and then
I can map between the two - the whole point of ORM really.
> That being said, if you have
> a legacy DB, or you start developing DB first, then, yup, you will have to
> jump through some hoops to get to where you want to go OO wise - or you may
> not get there at all.
And what a lot of people seem to forget (or not want to deal with) is
that you can always write adapter objects to enable your nice, clean,
well-designed business object model to map onto a (completely
different) nice, clean, well-designed relational data model.
I (used to) do that because (I used to) spend a lot of time doing them.
Now, with AOP, Reactor etc I don't have to pay much attention at all :-)
*However* we do still need to keep talking about OO, because there are a vast
number of CF developers out there (well, at Scotch anyway !) that are not
using OO at all - and building some fairly large apps.
Maye their code is very good, but I bet taking an OO approach (yes, maybe
using a Pattern or two) would make it better.
--
Tom Chiverton
****************************************************
This email is sent for and on behalf of Halliwells LLP.
Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by The Solicitors Regulation Authority.
CONFIDENTIALITY
This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500.
For more information about Halliwells LLP visit www.halliwells.com.
Something that came out of the 'requirements and estimating' talk Peter did at
Scotch was 'what if you could be *more productive*'.
Agreed. It's true.
But... people should have a start point to learn OO.
And... the main one is the practice (and books, simultaneously).
When people goes to the practice they tend to follow the models used by the big architects. That's good.
I don't thing it is "to blindly apply patterns". Because it's just a start point, the initial architecture.
As way as the project grows the programmers will see why some patterns apply and others not.
I think this is a (my) way to learn.
In most of case it's not good to disagree with some patterns because we still don't feel ourselves in the same level of experience in OOP than all of you.
Thats why we prefer to ask instead of argument.
So, why the same question (DAO x Gateway) hits the same mailling list often?
Because it was never answered in a common. (well, perhaps it don't has - so the doubt remains).
I don't know until where it's good or not.
In one hand everyone have to have yours thoughts and feelings about OOP for the patterns continues to evolve.
In the other hands the CF community doesn't have a set of Best Practices for OOP.
I'd just like to thank you all for the replies with your valuable opinions.
I agree with most of said in the thread and it helped me to clarify some
things in my mind.
Thanks in advance,
Ronan