This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Pattern question for gurus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Pattern question for gurus" Watch "Pattern question for gurus" New topic
Author

Pattern question for gurus

Sam Carlac
Greenhorn

Joined: Oct 05, 2011
Posts: 18
Guys,

In my design, I originally had two SessionFacades which were injected into JSF managed beans. I soon realized I didn't like this approach because:

a) the managed beans had two dependencies each to the session facades;
b) the class diagram had too many overlapping (crossing) dependency lines because of this.

So as an alternative, I decided to have a central SessionFacade which the managed beans depend on, and then that SessionFacade in turn uses the other two SessionFacades:



So my question is... Is the SessionFacade(X) actually a BusinessDelegate? Or can this actually be a SessionFacade? It will be injected into the Managed bean via dependency injection.

Thanks,
-Sam
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

I don't think it is a business delegate because a business delegate is for shielding remote communications.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sam Carlac
Greenhorn

Joined: Oct 05, 2011
Posts: 18
Thanks Jeanne. Good point... But do you see anything wrong with this approach? I fear that it is not the most standard way, and / or it may just be adding unwanted complexity. Has anyone seen this before?
Eduardo Mineo
Ranch Hand

Joined: Sep 26, 2011
Posts: 63

Sam, are the facade A and B so specific (or big)? Why don't you merge both in facade(X)?
Sam Carlac
Greenhorn

Joined: Oct 05, 2011
Posts: 18
They encapsulate logic for different things. SessionFacade X really only centralizes transaction management and security, delegating calls to the other two facades.

SessionFacade X has all the methods which SessionFacade A and B have - it just delegates (this is what i don't like). I thought of putting all logic into X, but thought that was a bit messy.

hmm. Im thinking I can leave as is if I explain my reasons properly.

Thanks.
Tamal Guha
Greenhorn

Joined: Jun 28, 2011
Posts: 9

Sam Carlac wrote:They encapsulate logic for different things. SessionFacade X really only centralizes transaction management and security, delegating calls to the other two facades.

SessionFacade X has all the methods which SessionFacade A and B have - it just delegates (this is what i don't like). I thought of putting all logic into X, but thought that was a bit messy.

hmm. Im thinking I can leave as is if I explain my reasons properly.

Thanks.


Hi

I look into it this way:
Firstly: 'They encapsulate logic for different things' - so the managed bean has two distinct types of functionalities. Adding one more 'facade' does not help much practically, just an extra later. I would keep it first way you did, it is simpler.

Secondly: Seems managed bean(and hence ui page) is supporting a lot of functionality. Is it possible to split two groups of functionalities in different pages (and use two managed beans) ?
(even say, one jsp includes another jsp..and so on )

Sorry, I was probably of not much help... but thats how I would have thought through the problem.

Thanks
-tamal


SCJP 1.4, SCJD-1.4, SCBCD-5, OCMJEA-5.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pattern question for gurus
 
Similar Threads
Correct way to assign a value to a managed bean from a class?
Dependency Injection DI concept
JSF, EJB, JPA design quandaries !!!
General design questions
FacesServlet in a sequence / class diagrams