1
Good night,
In my project I have an application layer where the class is structured as follows:
namespace ProjetoTreino.Aplicacao { public class PessoaAplicacao { private readonly IRepositorio<Pessoa> repositorio; public PessoaAplicacao(IRepositorio<Pessoa> rep) { repositorio = rep; } public void Excluir(Pessoa entidade) { repositorio.Excluir(entidade); } public void Inserir(Pessoa entidade) { repositorio.Inserir(entidade); } public Pessoa ListarPorId(int id) { return repositorio.ListarPorId(id); } public IEnumerable<Pessoa> ListarTodos() { return repositorio.ListarTodos(); } public void Update(Pessoa entidade) { repositorio.Update(entidade); } } }
I wanted to know if it is really right to declare this property and this constructor this way or if I should declare Irepositorio to take the direct Repositorio since the Repositorio inherits from Irepositorio, And also whether I could instead declare the property already inherited from it as in the example:
public class PessoaAplicacao : Repositorio<Pessoa>
It would not be the case to inherit the interface?
– Leandro Angelo
I don’t understand, inherit the interface?
– Gabriel Coletta
but instead of me declaring a private property readonly Irepositorio<Person> repositorio; thus, seeking from Irepositorio, could not directly refer to Repositorio, instead of the interface ?
– Desalex
The reference is Irepositorio, but actually behind there is a component that will be doing a new Repositorio<Person>(). he will not be "seeking" from Irepositorio.
– Gabriel Coletta