I have just started playing with ASP .NET-Core and I am building my own application. I have decided to have multiple types of users and I wanted to play around with authentication and Identity.
Let us suppose we have a basic interface 'IUser' and some user types such as 'Admin', 'Medic', 'Patient', 'Receptionist'. Since those are users, they will also be application models, thus inherit 'IDentityUser'. At this point, I wanted that every user model to implement 'IUser', but then decided to better separate the interfaces, thus comming up with this: preserver 'IUser' and create a separate interface for every type of user.
Let us suppose that we have the interface called 'IMedic' which extends 'IUser', implemented by Medic model. Is this a good practice? I suppose that segregating the interface a bit more give me more flexibility, but at the same time if the base interface, i.e. 'IUser' gets modified, all the other interfaces and models must comply. How would this impact the lifecycle of an application, let it be an MVC application?
Now, for a more specific question, what methods should I add to those interfaces? I know the importance of design patterns and I would not want to have only concrete classes inside my app, but rather have more flexibility using more interfaces, now allowing empty interfaces at all.
Some code snippets:
public interface IUser
{
//some general methods
}
public interface IMedic : IUser
{
//some model-related methods
}
public class Medic : IdentityUser, IMedic
{
//some code here
}
Thanks!
Aucun commentaire:
Enregistrer un commentaire