The following is an email from a system designer about the interface design between components and subsystems. The text is slightly changed.
*************************
Thank you for your trust. I have read your document and the main points of interface design are covered. I personally think it is good !!
On the technical level, I would like to mention some of my immature views for your reference:
===
Type of the Value Object Property. The resource result set attribute rshashmap in the resource result interface is a set of name/value pairs. It is defined as the hashmap type in this document, and hashmap is an implemented class. Here I suggest changing it to the map interface type. Rshashmap (or rsmap) may be accessed and used by callers. Using interfaces or more superclasses can reduce the coupling level between caller and callee (rsmap, this is the basic principle of object-oriented design. It is also important to reduce the coupling level in process-oriented design. For callee, it can implement the real object type of map as hashmap, or it can be implemented as linkedhashmap, so there is more room for selection. This problem is not fatal. In fact, it is acceptable not to change it, but the code quality looks a little better after it is changed.
The Java language provides developers with the basis for object-oriented development. Specifically, the resource result class is implemented as a JavaBean and the getter/mutator method is defined for the rsmap attribute. The implementation code is as follows:
Package com. Acme. test;
Import java. util. Map;
Import java. util. hashmap;
Public class resource {
//... Other attributes
Private map resourcemap = NULL; // resource result set
Public map getresourcemap (){
If (resourcemap = NULL)
Resourcemap = new hashmap (); // implement as hashmap
Return this. resourcemap;
}
Public void setresourcemap (MAP resourcemap ){
This. resourcemap = resourcemap;
}
}
===
The expression of the interface design between subsystems. Using tables to express interface design is also a classic choice. Here I combine my previous development practices with my experience in UML/OOA & D training and propose another expression method as a supplement, it is only for pioneering ideas. Because it has reached the level of detailed design, it can be expressed by UML class diagrams, or expressed by Java code. The two are equivalent and can be converted to each other. The key to designing subsystems is interface definition and interface implementation separation.
See the appendix's Java code example. Because you have to watch too many things and have a tight schedule, you cannot start writing them. Sorry!
*************************
Package com. Acme. test;
Public interface crmquery {
// Query customer information
Public customer querycustomer (string custid );
// Query user information
Public user queryuser (string userid );
}
*************************
Package com. Acme. test;
Public class crmqueryimp implements crmquery {
// Query the customer information implementation code
Public customer querycustomer (string custid ){
Customer customer = new customer ();
// Todo: Query implementation code
Return customer;
}
// Query user information implementation code
Public user queryuser (string userid ){
User user = new user ();
// Todo: Query implementation code
Return user;
}
}
*************************
Package com. Acme. test;
Public Class Customer {
Private string custid;
Private string custname;
// Other attributes
Public String getcustid (){
Return custid;
}
Public void setcustid (string custid ){
This. custid = custid;
}
Public String getcustname (){
Return custname;
}
Public void setcustname (string custname ){
This. custname = custname;
}
}
*************************
Package com. Acme. test;
Public class user {
Private string userid;
Private string username;
// Other attributes
Public String getcustid (){
Return userid;
}
Public void setcustid (string userid ){
This. userid = userid;
}
Public String GetUserName (){
Return username;
}
Public void setusername (string username ){
This. Username = username;
}
}
*************************
Package com. Acme. test;
Import java. util. Map;
Import java. util. hashmap;
Public class resource {
//... Other attributes
Private map resourcemap = NULL; // resource result set
Public map getresourcemap (){
If (resourcemap = NULL)
Resourcemap = new hashmap (); // implement as hashmap
Return this. resourcemap;
}
Public void setresourcemap (MAP resourcemap ){
This. resourcemap = resourcemap;
}
}