jeudi 11 juin 2015

Developer class with one or more expertises

Let's say we have a simple class Developer:

public class Developer 
{
    private String name;

    public Developer(String name) {
      this.name = name;
    }
}

A developer can have one or more expertises, for example there could be a developer that's an expert in SQL and Java. There can also be a developer that's just an expert in SQL.

What's the best pattern for this situation?

My way of doing it would be to create an interface for each expertise and let Developers implement the necessary interfaces.

But this brings me to another question. Let's say we have a company that is looking for developers with a specific expertise (f.e. SQL). How would I check if a Developer has the expertise "SQL" without using instanceOf because this is considered a bad code smell.

Aucun commentaire:

Enregistrer un commentaire