Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [adapter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
4 answers
145 views

Adapter or pure interfaces?

I got a bit strange 'future ready' scenario. And I'm not sure if I got it right in regards to C# adapter design pattern. The scenario is that to be future ready, 'to use the adapter pattern' to easily ...
user avatar
  • 137
1 vote
2 answers
1k views

To which Clean Architecture layer should repositories implementations belong?

It's very common to see this use of repository in projects using clean architecture: interface Hero { } interface HeroRepository { findById(id: number): Hero; } class FetchHeroUseCase { ...
user avatar
1 vote
1 answer
66 views

Adapt very different adapters to an Interface

I'm building a service to send push notifications to the user. At first, I designed an Interface for the push notification adapters, something like this: interface PushNotificationAdapterInterface { ...
user avatar
5 votes
1 answer
1k views

DDD: Viable approaches to integrating with external systems (Adapters, ACLs, Bounded Contexts)

Our team have been debating approaches to integrating external or third party systems when using DDD. The literature is extensive, but sometimes contradictory. Just like a UL helps us better ...
user avatar
  • 161
2 votes
1 answer
140 views

Is this a valid GoF Adapter example?

After visit dozens of pages searching a "non-sockets-or-iphone-conceptual-example" of Adapter Pattern, I have found this one: Lloyds bank is an international bank offers services worldwide. For ...
user avatar
  • 243
0 votes
0 answers
88 views

Instantiating adapters in onion architecture

GitHub and NuGet Do you use connection strings to instantiate your adapter services or just always configure it through IoC? I think that connection strings could provide a way more flexibility, ...
user avatar
0 votes
1 answer
101 views

Is a JSON wrapper an adapter?

Please let me illustrate with a simple example. Suppose we have a Weather object: class Weather: def get_forecast(self, day, place): forecast = "code that calculates forecast" ...
user avatar
2 votes
0 answers
34 views

Manage web service with different version

My vendor can log in to a master management system (System A) which manage multiple subscriptions of a SaaS (System B). Each System B is hosted separately on an isolated server. System A and system B ...
user avatar
  • 147
2 votes
1 answer
343 views

Is an Adapter pattern a Proxy pattern? If not, why not?

A common use of the adapter pattern is to support functionality that isn't actually supported in an underlying class. For example, if I use an API to interact with a Samsung Smart TV, I might want to ...
user avatar
  • 2,011
7 votes
3 answers
2k views

How to use 'Adapter' without any changes in the existing code in c++

Here we have TV class and DVD class as example: class TV { public: TV(); virtual ~TV(); void on() const; void off() const; }; class DVDPlayer { public: DVDPlayer(); ~...
user avatar
  • 91
0 votes
1 answer
3k views

How to name different components in adapter pattern?

(example code in PHP, but this can apply to more languages) I have a scenario with an adapter pattern, where I have classes, interfaces and objects with different roles, like so: An original object ...
user avatar
3 votes
2 answers
269 views

C# Adapter pattern - Condition based execution

I am building a solution for the recruitment division of an organization. The requirement is to create new employee records in the organization's database for the applicants who have cleared the ...
user avatar
  • 141
7 votes
1 answer
449 views

I need to be able to adapt my type to theirs, and theirs to mine

I have a situation where I have an external library. In short, I need to be able to adapt my type to theirs, and theirs to mine. The library has a collection like so: interface IExternalCollection { ...
user avatar
15 votes
1 answer
5k views

Unit testing an API client and wrappers

I've been going round in circles trying to figure out the best way to unit test an API client library I'm developing. The library has a Client class which basically has a 1:1 mapping with the API, and ...
user avatar
-1 votes
1 answer
4k views

What is the difference between Adapter and Delegation design pattern?

I am very confused about Adapter and Delegation design pattern. In Adapter pattern we bring an intermediate class to interact with another class. And in Delegation pattern we also bring an ...
user avatar
34 votes
6 answers
6k views

How do I test a system where the objects are difficult to mock?

I am working with the following system: Network Data Feed -> Third Party Nio Library -> My Objects via adapter pattern We recently had an issue where I updated the version of the library I was ...
user avatar
  • 7,502
1 vote
1 answer
2k views

Is it possible to avoid a lot of using statements?

Lets say I have a simple code like this (fiddleLink): using System; public class Program { public static void Main() { //Dependency register logic here var service = new ...
user avatar
  • 121
3 votes
1 answer
2k views

C# Dependency Injection with Adapter Pattern

In the following code sample, I have a client that works through a controller. In my specific case the controller establishes a session to an address on a GPIB bus. An instance of this is then ...
user avatar
0 votes
2 answers
349 views

What pattern do I use and how do I implement it for one method that will be handled multiple ways

My scenario: I am creating an application that will allow me to create a mapping of redirect url's that will point from the request url (the url in the old ecommerce solution) to the target url. There ...
user avatar
1 vote
1 answer
1k views

What is the point behind building an abstraction layer PDO Adapter class instead of using native PDO?

I have built a PDO adapter class because I thought, at the time anyway, it would be a good idea. After fighting with it, it makes no sense to me. Isn't the design of PDO the way it is to keep you ...
user avatar
  • 3,629
1 vote
1 answer
523 views

Interfaces, Adapters, exposing business objects via WCF design

I know there have been countless discussions about this but I think this question is slightly different and may perhaps prompt a heated discussion (lets keep it friendly). The scene: I am developing ...
user avatar
  • 171
0 votes
1 answer
1k views

How to unit test a class which is just an adapter that logs input and output to a third-party library?

I have the following (in C#, but the question could also apply to Java): public interface ILibraryAdapter { string Property1 { get; } string Method1(string param1); ... } public class ...
user avatar
26 votes
4 answers
36k views

How should I add functionality to an object that already exists?

I have an interface that has a certain amount of well-defined functionality. Let's say: interface BakeryInterface { public function createCookies(); public function createIceCream(); } This ...
user avatar
5 votes
3 answers
302 views

Is there an efficient way to adapt data from a structure to another in c++?

I'm writing an interface between two configuration models that use different structures. While I know that there is no "magic" way to do the translation from a structure type to another, I wandered if ...
user avatar
2 votes
2 answers
128 views

Should one define an interface and code an adapter for it whenever a dependency is found?

Given a particular third-party class/library you want to make use of, the simplest thing to do would be to just hardcode API calls to it through your application. On the other hand you have the ...
user avatar
  • 3,269