File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design Patterns Question

 
Sayali Mahindrakar
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(1)Which one of the following is a key difference between the Adapter
and Facade Structural Design Patterns?
a)The Adapter defines a new Interface; the Facade reuses an existing one.
b)Facade is an extension of the Adapter.
c)The Adapter defines a new Interface; the Facade combines two existing Interfaces.
d)The Facade defines a new Interface; the Adapter reuses an existing one.
e)The Facade defines a new Interface; the Adapter combines two existing Interfaces
I think d is correct. An adapter does not define a new interface. What do you all think
 
Vladan Radovanovic
Ranch Hand
Posts: 216
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Adapter converts the interface of a class into another interface client expects while
Facade provides unified (higher level) interface to a set of interfaces in a subsistem.
so the answer is I guess d.
[This message has been edited by Vladan Radovanovic (edited February 22, 2001).]
 
Tony Chen
Ranch Hand
Posts: 286
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sayali Mahindrakar:
d)The Facade defines a new Interface; the Adapter reuses an existing one.

I agree with you guys.
According to GoF, the Intent of Adaptor is: Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. A class adapter uses multiple inheritance to adapt one interface to another; an object adapter relies on object composition.
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sayali Mahindrakar:
(1)Which one of the following is a key difference between the Adapter and Facade Structural Design Patterns?
a)The Adapter defines a new Interface; the Facade reuses an existing one.
b)Facade is an extension of the Adapter.
c)The Adapter defines a new Interface; the Facade combines two existing Interfaces.
d)The Facade defines a new Interface; the Adapter reuses an existing one.
e)The Facade defines a new Interface; the Adapter combines two existing Interfaces

Adapter Pattern - When you have to implement an interface, but you want to use another class (or interface's) methods in order to implement it you are using the Adapter Pattern.
Facade Pattern - Facade is a high level interface that masks lower-level subsystems. In EJB distributed object architecture, sessions beans can be used to provide a high-level interface to a facade to business processes, masking the lower-level entity bean subsystems used behind the scenes.
So d is correct.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic