Let's apply what we now know about the SOLID class design to our app. Given that abstractions are important in SOLID design, we will begin by adding abstractions for our repositories.
In .NET, we create an abstraction through an interface
and provide a concrete implementation of an abstraction through a class
, so our first step should be providing interfaces for our classes.
Open Visual Studio and add new files, namely IRecipeRepository
, IStyleRepository
, and IReviewRepository
in the Repositories
folder of our project to hold the interface for each repository in the app. The extracted interfaces for IRecipeRepository
is as follows:
public interface IRecipeRepository { IQueryable<RecipeEntity> GetRecipes(); IQueryable<RecipeEntity> GetRecipesByStyle(string styleName); RecipeEntity GetRecipe(int recipeId); void Save(RecipeEntity recipe); }
These interfaces are narrow in scope and adhere to ISP. While they will also be...