jeudi 11 juillet 2019

Is it ok to initialize a util class before using its methods?

Is it a design smell if I have to call the init method of a util class before I can use its methods ? Is the following code a bad design for util class ?

public class MyUtils {
    private static MyObject myObject;

    public static void init(MyObject testObject) {
        myObject = testObject;
    }

    public static void closePDFWindow(String myString) {
        myObject.displaySomthing(myString);
    }
}

Aucun commentaire:

Enregistrer un commentaire