You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jeff Duska <Je...@noaa.gov> on 2002/06/27 01:43:04 UTC
Velocity and Data Access Layer Questions...
I'm using VelocityServlet project. My goal is to create a several
Velocity Library Tools that are implement the business objects.
I was using the model suggest by Martin Fowler called Row Data Gateway.
I tweaked this for the recommendation from Block in Effective Java to
use static factor instead of a constructor. In my case, I have
findbyRandomNumber(String rnd).
In my test code I just would have
PurchasedProduct pp=PurchasedProduct.findbyRandomNumber...
I wanted to have something like this for my template users
#set ($pp= PurchaseProduct.findyRandomNumber...)
$pp.isFree
The problem is that this doesn't work with VelocityServlet, because
there isn't a public construtor. I could change from a factory to a
method, since the object already exists. What happens when I want to
create another instance of the object?
I could refactor this into two classes. The business object and another
object that is the factory. My only concern is that I know have quite a
few classes.
Right now it does findbyRandomNumber
creates a ProductPurchaseFinder (does all the db stuff)
uses the ProductPruchaseFinder to create the ProductPurchaseGateway
ProductPurchase would then have function for the business rules
using a the private instance of ProductPurchaseGateway to stored the
data
I use the wrapper on ProductPurchase, because I like to replace my
database code with something like JDO, Torque or Castor at a later date.
At this point, I would need to create ProductPurchaseFactory to hold the
factory functionality. Does this make sense? I'm worried I've made this
too confusing. I really do expect to rip out the database code in future
release.
What are you suggestions?
Regards,
Jeff Duska
I
data acessand I have created a classes that Tools
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>