namespace app\action\user;class Login{ function get(){ } function post(){ }}
namespace app\action\user;class Login{ function service(){ } }
namespace app\action\user;class PostLogin{ function service(){ }}
What kind of design is more reasonable?
Reply content:
namespace app\action\user;class Login{ function get(){ } function post(){ }}
namespace app\action\user;class Login{ function service(){ } }
namespace app\action\user;class PostLogin{ function service(){ }}
What kind of design is more reasonable?
The individual thinks to divide the specific use way. In the case of Singleton mode, two classes have no advantage, and a class is actually more encapsulated. A request for an instance, seemingly divided into two classes can reduce overhead, but I still think a class on the line.
Principle, get/put/post/delete to English a URL above the data set of four kinds of operations, code should be operating the same concept, so put in a class inside when 4 methods are very good. However, many times, we use post is not the original meaning of post, so look at your specific business logic is what it looks like.
This person likes to see, there is no absolute standard.
Another thing to consider is the routing overhead, but it's no different now.