jeudi 24 mai 2018

return type must be of object in designing the solution through design pattern

Please advise below I haveimplemented the starergy pattern as shown below as per the solution of the problem now my question is that apart from statergy design pattern is there any other better design pattern in which i can better express this problem in much efficient way , rite now below is the statergy pattern in which i have explained the problem

the interface

interface applyBuisnessRule<T> {
    public T execute(String jobCode) throws Exception;
}

the class

class CardvaletImpl<T> implements applyBuisnessRule<T> {
    private static final String Success = null;

    public T execute(String jobCode) throws Exception {
        T result = null;
         // put your logic and populate result here. I believe you are not going to return Success every time as it String
        return result;
    }
}

code excecution

CardvaletImpl<String> cardvaletImpl = new CardvaletImpl<>();
String result = cardvaletImpl.execute("JOBCODE");

Aucun commentaire:

Enregistrer un commentaire