1. Single Responsibility Principle
Single Duty principle: change only because of one factor
"Zen of Design Patterns", the author mentions that someone has written an interface like this
void changeuser (userob userob,changeoptions option);
It's better to write separately
void changeusername (String userName); void changeuseraddress (String address); void Changeusertel (String Tel);
Although, as the author mentioned, the following substitution above, in the end should not be replaced? See the code is not enough, do not know ...
In my view of the HGE engine code, the author is the combination of the two, provide the first interface, the internal implementation of the process will be divided into a second form of the function, called internally.
Well, like this.
Changeuser (user_name,"Lily"); Changeuser (user_address,"Heave "); Changeuser (User_tel,"138xxxxxx110");
Still like this one.
Changeusername ("Tom"); Changeuseraddress ("hell" ) ); Changeusertel ("189xxxxxx911");
- For extended functionality, the obvious above is not good enough, because the Changeuser function is to be modified
- If you want to modify the corresponding change function, the one above to modify the Changeuser and corresponding change function
--151120
Design Patterns-Single responsibility principle