Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Extension Objects Pattern and Adapter Pattern?

Can you explain me about this Extension Object Pattern and how it differ from the Adapter Pattern?

There seems to be only few resources in web that explains the Extension Object Pattern and most of them are bit confusing (at least for me).

Thanks in advance.

like image 453
vishnurajts Avatar asked Sep 05 '16 13:09

vishnurajts


People also ask

What is the difference between adapter and decorator pattern?

Main difference is: Decorator is used to decorate individual objects at run-time. Adapter is used to add features to the class and therefore to ALL of its objects. It's true that Adapter targets the class and therefore to ALL of its objects.

What is the difference between object adapter and class adapter?

The main difference: Class Adapter uses inheritance and can only wrap a class. It cannot wrap an interface since by definition it must derive from some base class. Object Adapter uses composition and can wrap classes or interfaces, or both.

What is extension pattern?

An extension fracture pattern is a kind of spinal fracture that happens when the small bones in your spine, called your vertebrae, separate from each other because they were extended too far.

What is the difference between Bridge pattern and Adapter pattern?

Adapter pattern is used after the application components are designed so that we can use them without modifying the source code. This is in contrast to the Bridge pattern, which is used before the components are designed.


1 Answers

The main difference is in the time of usage:

You would use an Adapter during development of your software, in cases you cannot change the existing interface you introduce an Adapter.

The extension object pattern provides for such changes and enables you to e.g. extend already deployed software.

Also, from the Text you posted:

Adapter supports to adapt an existing interface. The Extension Objects pattern supports additional interfaces. Extension Objects and Adapter can work together in situations where an object needs to be adapted to an extension interface.

like image 192
PsiX Avatar answered Sep 24 '22 20:09

PsiX