I retrieve an object from an external library, later on I need to return this object back to the library. Here's an example:
var user = dao.GetUser();
var team = dao.GetTeam();
team.Add(user);
I have already tried the following:
- Adapter external -> internal
- Adapter internal -> external
It looks like this:
var user = new UserAdapter(dao.GetUser());
var team = new TeamAdapter(dao.GetTeam());
team.Add(new ExternalUserAdapter(user));
The problem was, my internal interface now had to supply a vast number of methods that I didn't need since ExternalUserAdapter implements the external interface which is far bigger than I'd like.
I have also tried the N-Way-Adapter or Class Adapter pattern, but that didn't work, since I cannot convert an external user to an internal class adapter, ie. can't convert a cat to a dog just because they are both animals.
How can I solve this issue? I would love some blog, article or book reference addressing this issue
Aucun commentaire:
Enregistrer un commentaire