I was having a conversation with another developer when we discovered that we were not in agreement on what 'coarse' and 'fine' grained interfaces were. So now, I ask you!
Does the granularity deal with: A. The number of network trips necessary to carry out some CRUD process.
B. The naming pattern for the interface itself (e.g. getEmployeeName vs. getEmployee)
C. The granularity of the information sent or returned from the call (e.g. Was the NAME field sent/returned or was the EMPLOYEE record returned)
D. Some combination of A, B & C (spell out which combo)
Before answering consider the following interfaces: getEmployeeName(SSN) : returns Name field getEmployee(SSN) : returns Employee record get(Employee, Name, SSN) : returns Name field do(get, Employee, Name, SSN) : returns Name field do(string) : returns Name field do(GetEmployeeCommand) : returns Employee record
A) Yes it can. I think what you are dealing is the correct level of chattyness between the Client & the Server. Basically small calls like :
public String getName ();
public String getSurName ();
publicint getAge ();
are in the case of RMI or EJB better replace by
public PersonnalDataVO getPersonnalData ();
A simple "record-like" structure will be returned. Check the ValueObject Pattern. The pattern improves performances drastically by reducing the Chattyness.
B) This is trivial & complex. What is the name of the interface will be my answer ? If the answer is EmployeeInfo, the second one should apply. But this is a coarse answer. Basically, you should also consider the fact the interface may be on Contract or something similar... Hence, yes the naming convention will be impacted by the "coarsity" of the interface.
C) This is really a question of design. Ifyou are dealing with a networked application, the Employee should probably be returned... More exactly the EmployeeVO should be returned... may be that EmployeeVO would only contain the name.
D) You could have those :
publicinterface EmployeeInfo
{
public String getName (String anSSN);
public String getSurname (String anSSN);
publicint getAge (String anSSN);
// For remote calls use ***only*** this one
public EmployeeVO getEmployee (String anSSN);
}