Hoang, Hai typed the following on 09:33 AM 3/13/2002 -0600 >I really like the idea of having separated the business object and business >object manager into to separated classes for each table. For example, for a >user table you can have the following classes: > >Interface User >Interface UserManager >Class UserImp implements User >Class UserManagerImpl implements UserManager > >Where User contains getter/setter methods and UserManager manages the User >class and its relationship. I am wandering why torque is not follows this >design pattern? The advantage for this design is decoupling.
I use a UserManager pattern myself, to keep the view code independent of the database layer. If I wanted to make it able to use an alternative persistence package, I would make the interfaces as you suggest, turn my current UserManager into TorqueUserManager, and change the torque-based User class to implement the User interface (probably named something like UserIF). The only yucky part of this is that the User implementation is Torque-tied, so a different persistence package would require a separate implementation. But it should be kept faily simple anyway, basically just a bean. Any more complex functionality could be shifted out to a delegate class (perhaps not the right Pattern name), which would be persistence independant and shared by all implementations. Before doing that though, I'd look into what can be done with configuring torque - you can redefine what class to use as the base class, and probably some other stuff, so there's probably a cleaner way to handle it. >Also, is it worth for me to implement this feature in torque by letting the >UserManagerImpl uses the base/peer classes generated by torque currently. >Since I am new to torque, is there another way to accomplish the same thing? I would imagine your UserManagerImpl will need to be Torque specific - it needs to know about UserPeer. Your UserImpl ought to just be the User class generated as a stub by Torque - have it implement your User interface, add any extra functionality to it that isn't automatically implemented by BaseUser, and you're gold. Kief -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
