We have a data provider class that returns repositories for each aggregate in our database.
Let's consider following scenario:
public class DataProvider {
public IBookRepository Books { get { retun new BookRepository(); } }
public IAuthorRepository Authors { get { retun new AuthorRepository(); } }
}
As you can see, we return a new Instance of the given object every time we call the Member: DataProvider.Books.DoBANANAS();
vs.
public class DataProvider {
public IBookRepository Books { get; }
public IAuthorRepository Authors { get; }
public DataProvider()
{
Books = new BookRepository();
Authors = new AuthorRepository();
}
}
Will the call to `DataProvider.Books.BANANAS(); be less CPU / Memory heavy now?
As I just got around implementhing both version and they suprisingly worked!
But my experience tells me that Version 1 Sucks. Yet I've got more than enough time to fully optimize and implement the final product. (That's one of the benefits of working in a research group)