Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 干净的建筑。对方案的理解_Java_Android_Clean Architecture - Fatal编程技术网

Java 干净的建筑。对方案的理解

Java 干净的建筑。对方案的理解,java,android,clean-architecture,Java,Android,Clean Architecture,你能帮我理解下一件事吗?所以,我读了R.Martin的《清洁建筑》,里面有很多方案 图片1: 我的实施: Billing.java public class Billing { public Billing(){ //creating of licenses License personalLicense = new PersonalLicense(); License businessLicense = new BusinessLi

你能帮我理解下一件事吗?所以,我读了R.Martin的《清洁建筑》,里面有很多方案

图片1:

我的实施:

Billing.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
License.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
PersonalLicense.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
BusinessLicense.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
图片2:

我的实施:

U1Ops.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
U2Ops.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
U3Ops.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
OPS.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
User1.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
User2.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
User3.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
图片3:

我的实施:

权限。java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
User1.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
强调实施

IPermissions.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
权限。java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
User2.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
这些方案的共同细节如下:

Main.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
ITest.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
Test.java

public class Billing {

    public Billing(){

        //creating of licenses
        License personalLicense = new PersonalLicense();
        License businessLicense = new BusinessLicense();

        //method using
        personalLicense.calcFee();
        businessLicense.calcFee();
    }
}
public interface License {
    public void calcFee();
}
public class PersonalLicense implements License {

    public PersonalLicense(){
        //constructor implementation here
    }

    @Override
    public void calcFee(){
        //method implementation here
    }
}
public class BusinessLicense implements License {

    //private ? users - Unknown type just for example

    @Override
    public BusinessLicense(){
        //constructor implementation here
    }

    public void calcFee(){
        //method implementation here
    }
}
public interface U1Ops{
    public void op1();
}
public interface U2Ops{
    public void op2();
}
public interface U3Ops{
    public void op3();
}
public class OPS implements U1Ops, U2Ops, U3Ops{
    public OPS(){ ... }

    @Override
    public void op1() { ... }

    @Override
    public void op2() { ... }

    @Override
    public void op3() { ... }
}
public class User1 {
    public User1(){
        OPS u1Ops = new U1Ops();
        u1Ops.op1();
    }
}
public class User2 {
    public User2(){
        OPS u2Ops = new U2Ops();
        u2Ops.op2();
    }
}
public class User3 {
    public User3(){
        OPS u3Ops = new U3Ops();
        u3Ops.op3();
    }
}
public class Permissions{

    public Permissions() { ... }

    public classMethod() { ... }
}
public class User1 {
    public User1(){
        Permissions p = new Permissions();
        p.classMethod();
    }
}
public interface IPermissions{
    public void interfaceMethod()();
}
public class Permissions implements IPermissions{

    public Permissions() { ... }

    @Override
    public interfaceMethod() { ... }
}
public class User2 {
    public User2(){
        IPermissions p = new Permissions();
        p.interfaceMethod();
    }
}
public class Main {
    public Main(){
        ITest t = new Test();
        t.someMethod();
    }
}
public interface ITest{
    public void someMethod()();
}
public class Test implements ITest{

    public Test() { ... }

    @Override
    public someMethod() { ... }
}
我对这些计划了解得对吗

图1:
许可证
个人许可证
业务许可证
正常,
计费
必须如下所示:

公共类计费{
私人Lisense许可证;
公共计费(许可证){
this.license=许可证;
}
公帑{
//一些代码
此.license.calcFee();
//一些代码
}
公共许可证(许可证){
this.license=许可证;
}
}
它看起来像,它允许您定义一系列算法(
许可证
),将它们放入一个单独的类(
个人许可证
业务许可证
),并使它们的对象可互换。主要功能是
Billing
类只知道它有一些许可证对象,它可以
calcFee
,而不知道具体的实现。稍后,为了支持新的许可证类型,您将创建
许可证
的新实现,并且不会修改
计费

图2:
User1
User2
User3
,必须是类似的,并具有相应的U*OP:

公共类用户1{
私人U1Ops U1Ops;
公共用户1(U1Ops U1Ops){
此.u1Ops=u1Ops;
}
}
//类的使用
OPS=新OPS();
User1 User1=新User1(ops);
User2 User2=新User2(ops);
看起来像是接口隔离原则的示例,它指出不应强制任何客户端(
User1
User2
User3
)依赖于它不使用的方法(
User1
只需要
op1()

图3:
与前面的示例一样,必须使用
User
实例字段实现关联。这些图表演示了(上面是坏习惯,下面是好习惯)。根据它,
用户
必须只知道一些抽象的
权限
接口,而不知道具体的实现,
权限
类只知道它实现的
权限
接口。使用此原则,
实体
模块创建自己的抽象级别()-
权限
接口和使用它的
授权人。与之相关的术语通常在java框架(例如)中用于低层模块

我不知道如何回答您的问题。您想知道模式是否与您的代码匹配,或者模式背后的想法是什么?请详细说明你的具体问题。@Bram是的,你说得对!模式与我的代码匹配吗?因为我想如果他们这样做了,我就明白他们是对的,我想我明白了。你知道,我认为如果
Billing
使用图片1中的
License
,这意味着我们使用
PersonalLicense
BusinessLicense
)的
License
的新实例(
BusinessLicense
),在
Billing
内键入
Billing
,但实际上我们做了下一件事:
Billing b=新的账单(new PersonalLicense())
Billing b=new Billing(new BusinessLicense())
。简而言之,我们为每个
许可证
实现创建新实例,并将它们放在
Billing
中,它只知道它有一些
许可证
对象,对吗?