Documentum sample code is never deeply commented, so my question is:
What does this line mean?
IDfQuery query = DfcUtils.getClientX().getQuery();
An answer to an old question, but the original poster asked what the line means, not what alternatives may be used.
The line is creating an instance of an IDfQuery implementation, from a factory method within an instance of an object created by the static factory method within a DFCUtils class. This object is then assigned to a variable.
So: -
This is a typical factory pattern, where the method/function getQuery() determines what object type to return, based on rules or configuration settings. This is preferable than creating an instance of a concrete class, when several implementations of an interface are available. Typically, a factory will act like a class bootstrapper, initializing properties before returning the object to you.
Essentially, you may have a factory method containing a condition such as a switch statement that chooses which implementation to return, know as IOC (Inversion of control): -
public static IDfQuery getQuery(){
IDfQuery returnValue;
switch ( getDayOfWeek() ) {
case "Monday" : returnValue = new MondayQuery(); break;
case "Tuesday" : returnValue = new TuesdayQuery(); break;
case "Wednesday" : returnValue = new WednesdayQuery(); break;
case "Thursday" : returnValue = new ThursdayQuery(); break;
case "Friday" : returnValue = new FridayQuery(); break;
case "Saturday" : returnValue = new SaturdayQuery(); break;
case "Sunday" : returnValue = new SundayQuery(); break;
default: returnValue = null; break;
}
return returnValue;
}
public static String getDayOfWeek(){
return new SimpleDateFormat("EEEE").format( new Date() );
}