Ok, I read the stack overflow question โWhat does it mean toโ program for an interface โandโ understand. โI understand the benefits of using interfaces (at least I think I know). However, I have a little problem with by the fact that I'm currently working on what will be my first implementation of the interface.
I am creating a class to authenticate users on my site. I wrote it using static methods, so I can execute User.Authenticate (username, password). For me it is nice and easy. We look forward to three other types of members that can authenticate. Their authentication methods will point to different tables, etc. However, they still have to authenticate, change their password when changing passwords, to check their security question, etc. This seems perfect for the interface, but I have problems wrapping around how to do this.
User types are users, doctors, brokers, employers. For me, each class must implement a security interface that defines the methods mentioned above.
Can someone shed some light on how to do this And if my thinking is right?
You might want to take a look at ASP.NET/Microsoft membership . From your description, it sounds like you have users with different roles (doctor, broker, etc.).
"Interface programming" means designing a set of methods and properties that are the public "signature" of the functionality or service that the class provides.
You declare it as an interface, and then implement it in a class that implements the interface.
, , , .
.
, User.Authenticate(username, password) - , , ? ?
User.Authenticate(username, password)
- , , . (, , , ) , .
, , , , .
, . . , , , , . , , ILogon - , , "" , .
, -, , , .
, , .
Cade - . , , .
//Defined Classes class UserType1 : SecurityInterface class UserType2 : SecurityInterface class UserType3 : SecurityInterface //Use classes SecurityInterface authentication = GetCorrectUserTypeObject(); //the methds gets the correct UserType object base on who is supposed to authenticate. authentication.DoAuthenticate();
. , , , . , , , . , . , , - (, SQL AD, SQL).
, , , ( MemberhipProvider), , . / , .
- , - .
All types of users you mentioned are users. I worked on a variety of sites that had a limited approach in which they referred to the first type of user that was written as โuserโ on the site, and then any additional user types added later were just awkward.
My suggestion: do not call one of your users "user". These are all users of different types or roles.
Source: https://habr.com/ru/post/1702145/More articles:State Chart Generator - c ++ASP.NET Membership in Web Administration - asp.netMS Access Moving records to fields - ms-accessThe effects of incorrect initialization spring - javaSmoothing relational data for summary / export - sqlC ++ RAII Replication in C # - c #How to force image caching with meta-update? - htmlGeneral Enforcement - genericsUSB flash drive - embeddedBest way to create a โrunnerโ script in Python? - pythonAll Articles