Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's the problem :

While implementing a C# wrapper for an online API (Discogs) I've been faced to a dilemma : quite often the responses returned have mostly similar members and while modeling these responses to classes, some questions surfaces on which way to go would be the best.

Example :

Querying for a 'release' or a 'master' will return an object that contains an array of 'artist', however these 'artists' do not exactly have the same members.

Currently I decided to represent these 'artists' as a single 'Artist' class, against having respective 'ReleaseArtist' and 'MasterArtist' classes which soon becomes very confusing even though another problem arises : when a category (master or release) does not return these members, they will be null. Though it might sound confusing as well I find it less confusing than the former situation as I've tackled the problem by simply not showing null members when visualizing these objects.

Is this the right approach to follow ?

An example of these differences :

public class Artist
    public List<Alias> Aliases { get; set; }
    public string DataQuality { get; set; }
    public List<Image> Images { get; set; }
    public string Name { get; set; }
    public List<string> NameVariations { get; set; }
    public string Profile { get; set; }
    public string Realname { get; set; }
    public string ReleasesUrl { get; set; }
    public string ResourceUrl { get; set; }
    public string Uri { get; set; }
    public List<string> Urls { get; set; }

public class ReleaseArtist
    public string Join { get; set; }
    public string Name { get; set; }
    public string Anv { get; set; }
    public string Tracks { get; set; }
    public string Role { get; set; }
    public string ResourceUrl { get; set; }
    public int Id { get; set; }

Edit :

I decided to keep things as simple as they can be : separated.

enter image description here

There are few weird names but it'll always be less confusing than the previous situations.

share|improve this question
It might help to have an idea of what's different. – Erik Reppen Jun 28 '13 at 0:06
I've just added an example. – Aybe Jun 28 '13 at 0:26
up vote 2 down vote accepted

I've also ran into similar issues and I ended up going the other way -- check out disqussharp for visceral details. The tactic I used there was a common base class with variants for things that changed between different calls.

I think having a single class -- or at least a common base class with the common properties -- is vastly more convenient for consumers and that is the way to go. There also isn't a law that says your classes that you return need to match the wire implementations if that makes more sense to callers of your library. If the service was that convenient then why would you be writing a wrapper in the first place?

share|improve this answer
Well I guess someone has to draw a line somewhere, to be honest I haven't understood everything from your project but it seems well crafted :-) – Aybe Jun 28 '13 at 13:29
Thanks, feel free to post any questions over on the project site if you've got them. Looking at the example you posted they really do seem like completely different classes in your case unless I'm missing something. – Wyatt Barnett Jun 28 '13 at 15:47
While they do relate to the same artist I've actually decided to keep it simple, I've kept everything separated. It took me the whole afternoon but now it can't be simpler than that even though there names like Artist, ArtistRelease, ReleaseArtist; I'll handle that in the documentation. Your library is on my desktop, this API is really interesting ! – Aybe Jun 28 '13 at 19:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.