samedi 4 août 2018

Data minimal principle, software architecture

i have a general question and didn't find any information.

I can remember that there is a principle, that you should only pass data, that is needed for the purpose of the execution.

But i ran into the following Problem with it:

I have multiple Callables in java:

public class CallableA implements Callable<Boolean> {
    private CallableData data;
    public CallableA(CallableData data) {
        this.data = data;
    }
}

public class CallableB implements Callable<Boolean> {
    private CallableData data;
    public CallableB(CallableData data) {
        this.data = data;
    }
}

public class CallableC implements Callable<Boolean> {
    private CallableData data;
    public CallableC(CallableData data) {
        this.data = data;
    }
}

For my opinion it is better to pass the same class CallableData(as you see above) to all Callables, so i dont need to specify many data classes. And each Callable uses the data from CallableData it needs.

Or it is recommend to define for every Callable its own Data class (CallableDataA,CallableDataB,CallableDataC)

But when for example CallableDataA and CallableDataB needs the same attribute, in CallableDataA and CallableDataA is reduntand information.

What is the best way to do it ?

Aucun commentaire:

Enregistrer un commentaire