• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

what design pattern is this?

hi experts,

From a java class(Action class) we are accessing the business delegate. The code is written in such a way that we are able to access/use  only the Business Delegate interfaces and the actual Business Delegate implimentation is hidden behind the Business Delegate interfaces. The main objective of the Business Delegate implimentation is to get a remote object(EJB object).

What Design pattern does the above statement represent?


thanks
J
0
jaggernat
Asked:
jaggernat
  • 2
  • 2
  • 2
  • +1
3 Solutions
 
ADSLMarkCommented:
Façade Pattern i think?

http://en.wikipedia.org/wiki/Fa%C3%A7ade_pattern

Mark
0
 
Ajay-SinghCommented:
Adapter pattern
0
 
ADSLMarkCommented:
My link is a bit weird, dont know why anyway let me try again:

http://en.wikipedia.org/wiki/Façade_pattern

So the question becomes, what's the difference.. look here:

Question: So the way to tell the difference between the Adapter pattern and the Facade pattern is that the Adapter wraps one class and the Facade may represent many classes?
Answer: No! Remember, the Adapter pattern changes the interface of one or more classes into one interface that a client is expecting. While most textbook examples show the adapter adapting one class, you may need to adapt many classes to provide the interface a client is coded to. Likewise, a Facade may provide a simplified interface to a single class with a very complex interface. The difference between the two is not in terms of how many classes they "wrap", it is in their intent. [Head First Design Patterns, p260]

(source: http://home.earthlink.net/~huston2/dp/facade.html)

Mark
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jaggernatAuthor Commented:
This is my actual scenario in j2ee project:

I have a scenario where I have this code in Action class
_____________________
OrderInfoDelegate orderInfoDelegate = (OrderInfoDelegate) DelegateFactory .getInstance().getDelegate("OrderInfo");
____________________

Where “OrderInfoDelegate”  is an interface which has this method
public interface OrderInfoDelegate
{
     public ControllingOrderVO saveOrderInfo(ControllingOrderVO conVO);

}
_________________________
And the actual implementation is in another class called LocalDelegateOrderInfo which goes like :

public class LocalDelegateOrderInfo extends BaseDelegate implements OrderInfoDelegate
{

private OrderInfoLocal local;
private OrderInfoLocalHome home;

public LocalDelegateOrderInfo(String jndiServiceHomeName) {
          try {
               home =
                    (OrderInfoLocalHome) ServiceLocator.getInstance().getLocalHome(
                         jndiServiceHomeName);
               local = home.create();
          } catch (ServiceLocatorException ex) {
               ex.printStackTrace();
          } catch (CreateException ex) {
               ex.printStackTrace();
          }
     }    

     public ControllingOrderVO saveOrderInfo(ControllingOrderVO conVO) {

          //ControllingOrderVO coVO = null;
               try {
                    conVO = (ControllingOrderVO) local.saveOrderInfo(conVO);
               } catch (EJBException ejbExp) {
                    throw logExceptionFromEJB(ejbExp, FFMLoggingLevels.DEBUG);
               }
               return conVO;
          }



}
_______________________

so when i am transitioning from action class to delegate , i am just calling the Delegate interface in my Action class.
So is it Adapter pattern or Facade?
0
 
Ajay-SinghCommented:
Façade simplifies the ways entities communicate, whereas Adapter may NOT. Adapter allows two or more previously incompatible objects to interact.
0
 
jaggernatAuthor Commented:
>>>Adapter allows two or more previously incompatible objects to interact.


in my case the two objects are compatible.
0
 
reach2piyushCommented:
Perfect fit - J2EE Business Delegate pattern

Close - Proxy Pattern

Business Delgates can be used as Adapters when the Business Services that it invokes is not a part of the same system.
But in this case the Business Delegate is acting more as a remote proxy for the Session Beans

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now