Let us discuss how Adapter Wrapper Design Pattern in this article:
It’s one of the structural design pattern. In daily development, we use adapter pattern at many places but sometimes we are not aware of terminology if adapter word is not specified 😁
The adapter pattern allows two components with incompatible APIs to work together by introducing an adapter that maps from one component to the other. You can adapt interface-interface, interface-implementation and implementation-implementation
This pattern is often used with factory, composition or decorator patterns.
User is Codable struct which conforms to Identifiable protocol as well for some requirement. User type already has identifier property but to satisfy protocol requirement it had to create identifier property using type extension, it’s called extension adapter. Extensions are a convenient way to add new methods and computed properties to any type in Swift without modifying its implementation.
If you extract UITableViewDataSource and UITableViewDelegate into separate class then it’s object adapter. Adaptee is HomeView and target is TableView.
Let’s go through terminologies:
This is a free third party commenting service we are using for you, which needs you to sign in to post a comment, but the good bit is you can stay anonymous while commenting.