Reader small image

You're reading from  Learning Python Application Development

Product typeBook
Published inSep 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785889196
Edition1st Edition
Languages
Right arrow
Author (1)
Ninad Sathaye
Ninad Sathaye
author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye

Right arrow

Adapter pattern


The adapter design pattern enables a handshake between two incompatible interfaces. Here, the incompatible interface of a class or a library is transformed into the one expected by your client code. This transformation is accomplished by an adapter class. The other class with a different interface than what the client expects is often referred to as an adaptee.

There are two broad categories of adapter pattern, namely a class adapter pattern and an object adapter pattern. In the former, the adapter inherits from the adaptee. It is possible to implement a class adapter in Python, as the language supports multiple inheritance. However, it is better to choose object composition (has a relationship) over inheritance. In the object adapter pattern, the adapter object has an adaptee object instead of inheriting from the adaptee class. The object adapter pattern helps maintain a loose coupling between the adaptee and the client code, wherein the client does not need to have any knowledge...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Python Application Development
Published in: Sep 2016Publisher: PacktISBN-13: 9781785889196

Author (1)

author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye