I have a Java class that does something like this
public class MyObjectUtil {
private final MyObject myObject;
public MyObjectUtil (MyObject myObject){
this.myObject = myObject;
}
public boolean isSomeInfoPresentValid() {
return myObject.isSomething();
}
public void modifyMyObjectInSomeWay(String blah) {
myObject.modify(blah);
}
}
Every time I have to create an instance of the Utility class to interact with a specific instance of MyObject.
myObject is present as an obj session
MyObjectUtil myObjUtil = new MyObjectUtil(myObject);
myObjUtil.modifyMyObjectInSomeWay("blah");
boolean valid = myObjUtil.isSomeInfoPresentValid();
To achieve the same result, I could statically perform the same operations with myObject each time as a method parameter.
public class MyObjectUtil {
public static boolean isSomeInfoPresentValid(MyObject myObject) {
return myObject.isSomething();
}
public static void modifyMyObjectInSomeWay(MyObject myObject, String blah) {
myObject.modify(blah);
}
}
, .
Util , myObject, . , , MyObjectUtil , myObject HTTP-.
?
MyObject , MyObjectXXXUtil MyObjectYYYUtil. Util ( myObject ) MyObject, . Util MyObject .