In order to provide access to the objects in my database, I created an interface for all the team members to be used like this (simplified example):
public interface IDatabase
{
ObservableCollection<Animal> Animals{ get; }
}
I didn't want the team to access internals like the database context or some oracle objects (encapsulation)...
I implemented two specific classes to be used in real life and for unit tests:
public class TestDatabase : IDatabase
{ }
public class OracleDatabase : IDatabase
{ }
After some usage the team members are asking for more and more functions, and I have to add methods to my interface:
public interface IDatabase
{
ObservableCollection<Animal> Animals{ get; }
ObservableCollection<Animal> Animals(Gender gender);
ObservableCollection<Animal> Animals(Gender gender, Race race);
}
Some of the filtering and sorting stuff could of course be done by the developer himself, but it is better located inside the database.
My problem now is that my interface is exploding, it's getting more specialized functions each day, it is far from stable and keeps changing all the time.
Is my design flawed right from the start?
Some ideas to solve that issue:
- expose the database context object to all developers (bad I think)
- add a function that accepts a linq query