The first {code...} and the second {code...} are more rational designs?
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(){ }}
Which design is more rational?
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(){ }}
Which design is more rational?
I personally think it should be divided into specific usage methods. In the singleton mode, two classes have no advantages. One Class is actually better encapsulated. One request to an instance seems to be divided into two classes to reduce the overhead, but I still think one class is enough.
In principle, GET/PUT/POST/DELETE are the four operations on the data set above a url in English. The Code should be the same concept, therefore, it is good to put four methods in a class. However, in many cases, the use of POST is not the original meaning of POST, so it depends on your specific business logic.
This is a matter of personal preferences, and there is no absolute standard.
There is also a need to consider the routing overhead, but now there is no difference