This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes BigSmoke inventory - Adapter or Facard? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "BigSmoke inventory - Adapter or Facard?" Watch "BigSmoke inventory - Adapter or Facard?" New topic
Author

BigSmoke inventory - Adapter or Facard?

Sandeep Krish
Ranch Hand

Joined: Jan 02, 2007
Posts: 58
Hello Dear Ranchers,

BigSmoke has an existing inventory system which is assumed to be intact as per my design proposed for their system enhancement. So I decided to use an Adapter to interface with inventory system as that would abstract inventory. Is this a right approch? What do you guys think.

warm regards
-Sandeep
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Abstraction through interfaces is always an optimal design. It sounds good to me!

-Cameron McKenzie
Sandeep Krish
Ranch Hand

Joined: Jan 02, 2007
Posts: 58
Thank you Cameron.
Do you think a business delegate is an overkill between the Adapter and Front controller? That is how i designed and the reason was to take care of exception and to abstract out the business method further. Adapter handling the business method exception dosen't look so good for me.

Have a good day
-Sandeep
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I always use a business delegate.

-Cameron McKenzie
Sandeep Krish
Ranch Hand

Joined: Jan 02, 2007
Posts: 58
Thank you again.

-Sandeep
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
I always use a business delegate.


Why? In EJB 3.0 the business interface is precisely that - the business interface. It doesn't throw checked infrastructure-related exceptions like EJB 2.1. In EJB 3.0, the business delegate and the EJB interface end up being identical, in which case there's no value in introducing a new layer. How does business delegate fit in with frameworks like Seam / WebBeans?


SCJP, SCWCD, SCBCD, SCEA 5
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
That is how I designed and the reason was to take care of exception...


What exceptions are you taking care of? Business (i.e. application) exceptions should be propagated to the client, otherwise there's no point in throwing them. The original intent of Business Delegate was to handle infrastructure related checked exceptions like RemoteException, FinderException, or CreateException. As I mentioned in my previous response, these exceptions don't exist in EJB 3.0.

... and to abstract out the business method further


Why? If you need to further abstract the interface of a boundary class, surely there's something wrong with the original interface. It sounds to me like you're mixing up Business Delegate with Service Facade.

Adapter handling the business method exception doesn't look so good for me.


That depends on where you want to introduce failover. I don't think Business Delegate was ever intended for that purpose. Proxy - yes, Business Delegate - no.
Sandeep Krish
Ranch Hand

Joined: Jan 02, 2007
Posts: 58
What exceptions are you taking care of? Business (i.e. application) exceptions should be propagated to the client, otherwise there's no point in throwing them. The original intent of Business Delegate was to handle infrastructure related checked exceptions like RemoteException, FinderException, or CreateException. As I mentioned in my previous response, these exceptions don't exist in EJB 3.0.


I am so used to EJB2.0 and did not remember the new feature available in EJB3! But still business delegate holds good due to following reasongs
1. It is desirable to minimize coupling between presentation-tier clients and the business service, thus hiding the underlying implementation details of the service, such as lookup and access.
2. Clients may need to implement caching mechanisms for business service information.
3. It is desirable to reduce network traffic between client and business services.

Why? If you need to further abstract the interface of a boundary class, surely there's something wrong with the original interface. It sounds to me like you're mixing up Business Delegate with Service Facade.

I too felt that there is something wrong the original interface and that is the very reason I posted this message! Service Facard is new for me so need to study that first before making any comments.

That depends on where you want to introduce failover. I don't think Business Delegate was ever intended for that purpose. Proxy - yes, Business Delegate - no.

I agree that BusinessDelegate is not intended for this purpose but since I decided to use it, I felt the extra functionality would beef up the Business Delegate.

Regards
-Sandeep
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
It is desirable to minimize coupling between presentation-tier clients and the business service, thus hiding the underlying implementation details of the service, such as lookup and access.


Dependency injection solves this problem.

2. Clients may need to implement caching mechanisms for business service information.
3. It is desirable to reduce network traffic between client and business services.


Remote clients.

I too felt that there is something wrong the original interface and that is the very reason I posted this message!


If you feel the interface is wrong then you need to go back and clearly define the boundary classes in the business tier. I don't see Business Delegate as the way to fix a poorly designed service.

Good luck
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Really good points by Jonathan and Sandeep.

Indeed, with EJB3, many of the tried and true design patterns have much less significance than they did in the past.

I actually put together a thread on Which Design Patterns are Not Needed in JEE5. It's an interesting discussion.

-Cameron McKenzie
Sandeep Krish
Ranch Hand

Joined: Jan 02, 2007
Posts: 58
Thanks Cameron and Jonathan! I am revisiting design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BigSmoke inventory - Adapter or Facard?
 
Similar Threads
WA #1.....word association
Tiers and layers - integration
Question on Part 2 : BigSmoke Cigar Assignment