samedi 17 août 2019

OOP, Design Software. Implements interface on separated class

I have an interface that has the methods of registration, login, recovery and one that returns the user. I need to implement the interface separately and export a global class from the package. That is, I have a package called authentication that has subsystems that implement the authentication and registration and return of information. How do I return all separate implementations in one class?

I have already tried extending all separate interfaces into a global interface where I also extend all classes that implement them into a package global. However it is only possible to extend a single class and not several at a time ...

import IUserAuthentication from "./userAuthentication/IUserAuthentication";

import UserAuthentication from './userAuthentication';
import UserRegistration from './userRegistration';

import IUserRegistration from "./userRegistration/IUserRegistration";
import {UserType} from "./userAuthentication/types";

interface IAuthentication extends IUserAuthentication, IUserRegistration {}

class Authentication  implements IAuthentication  {


    createAccount(email: string, password: string): boolean {
        return new UserRegistration().createAccount(email, password);

    }

    login(type: UserType, email?: string, password?: string): boolean {
        return new UserAuthentication().login(type, email, password);
    }

    logOut(): boolean {
        return true;
    }


}

export default new Authentication();

What I want is to access the class by calling it from the package and access all the functionality. But within the package divide them so that they are independent or almost. Thus having a very low coupling

Aucun commentaire:

Enregistrer un commentaire