Some Lessons Learned About Backend Development

The currently used framework is springmvc, and the original intention of the mvc code structure is as follows:

model model layer

view layer

control business layer

Those who have studied java development and used this framework should have a good understanding of these things. In actual development, the structure of our code is often view--->control -----> service------>dao.

In my understanding, the controller layer is where the user interacts with the view layer. The main business logic is handled here. Then the service layer, which is an implementation of control, but their relationship is n -> n. A service can theoretically be called by multiple controllers. Implement the separation of controller and service. Improve code reusability. In the same way, the service layer and dao should also be like this. The front and back ends are separated, and the controller, service and dao layers are separated.


Talk about the current problem. I currently write a code for file uploading. Then it was killed n times, and finally the boss helped write one, which only took half an hour. And how long did I do it, and how long did it take to change it. Analyze the reasons for such a large gap in what we do.

The business understanding is not smooth, and the ultimate purpose of an interface is not clear.

Too much code, too complex, lack of logic


Solutions to these problems:

1. Write my business logic and steps in control,


2. Separate controller from service and dao

The controller user interacts with the front end, completes the business logic by calling the service layer, and obtains the results required by the business

service The service layer, I call it that, because the things here are really similar to a service, and different businesses can be called.

dao mainly interacts with the database






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325490052&siteId=291194637