I ask if the following (example-class) code-snippets (having both the INTERFACE and the functional-CLASS-code in the same source-file) is good programming practice -OR- should the functional CLASS-code be moved to a separate code-file? The "IStudentService.cs" is the name of the combined source-file.
Based on the limitation imposed by SO moderator(s), to clarify my question -- it is related to the repository-pattern. Many Blazor/Maui tutorials and blogs suggest the repository-pattern. Since we are a small development team with many DB-tables and related services and repositories, I find it cumbersome to have so many source-files related to the application's functionality. I agree that (in the future) should we ever move to another implementation of the database tables we would then separate the functional-code (implementation) into its own source-file and place the additional implementation into its own source file. Comments on this clarification?
namespace Application.Services {
public interface IStudentService {
public Task<IEnumerable<Student>> GetAllStudents();
public Task<Student> GetStudentByUID(int uidStudent);
public Task<IEnumerable<Student>> GetStudentsByClassUID(int uidClass);
public Task<IEnumerable<Student>> GetStudentsByMajorUID(int uidMajor);
}
// functional-CLASS-code.
public class StudentService : IStudentService{
public async Task<IEnumerable<MOTRIP>> GetAllStudents() {...}
public async Task<Student> GetStudentByUID(int uidStudent) {...}
public async Task<IEnumerable<Student>> GetStudentsByClassUID(int uidClass) {...}
public async Task<IEnumerable<Student>> GetStudentsByMajorUID(int uidMajor) {...}
}
}
Thank you.