java - How to reduce coupling between Presentation & Business layers (JPA, Netbeans)? -


i working on java database project, , i'am doing best separate dal/bl layer presentation layer (web/desktop app).

somewhere, behind "search" button, must invoke method returns list of "oparticle" objects. in standard way, 1 should inject following code:

oparticlejpacontroller articlecpontroller = new oparticlejpacontroller(_emf); listarticle = articlecpontroller.findoparticleentities(); 

where "_emf" entitymanagerfactory instance supposed instanciated in application start-up.

i asking more efficient (cleaner) design pattern let me not obliged pass reference of "entitymanagerfactory (_emf)" controller classes, in presentation layer.

i thinking following approach:

listarticle = daofactory.getarticlecontroller().findoparticleentities(); 

where "daofactory" manages creation of controllers' objects follows:

c1 = daofactory.getarticlecontroller(); c2 = daofactory.getcustomercontroller(); etc... 

does violate best practice knowing must update factory adding new instanciation' method each time new controller or service provider class developed , added dal/bl layer.

best regards.

if way although need modify factory each time add controller can modify in compatible way doesn't break important oo principle.

but benefit lot if use dependency injection framework guice , leave emf dependency.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -