Java – get rid of GWT MVP template

About the location and attachment of the file activity MVP, I have to create each page:

>A place > an activity > a tokenizer (I must implement the tokenization logic) > presenter's interface (the activity implements this interface) > View's interface > view implementation > UI binder XML for view implementation > node in app activity mapper > a node in gin module, which is used to bind the view interface to view the implementation

I have created an application with basic functions (5 pages and navigation bar), and I have more than 1500 lines of code and ~ 40 files I think it's completely unmaintainable, but I haven't found any way to solve this problem Several frameworks (such as gwtp) implement MVP, but they also require the same number of templates

I can use spring MVC or play to achieve the same function in ~ 200 lines

What did I do wrong and how would you solve it?

Solution

I don't agree with you Compared with large files, the maintenance of a large number of small files is much better I agree that GWT is more verbose than spring MVC:

>Because of the dynamic nature of JSP, you don't need all these interfaces > JSP in sppring MVC has no strict type, and can automatically perform many low-level operations (such as data binding). > And do nothing at all (there is no need to clean up the view between requests, the view is stateless)

In the case of GWT, you have to do a lot of extra work due to the strictness of Java and state view It is fully maintainable (if done correctly) The main advantage is that you can add unit tests to the presentation layer Because of this fact, it will be more maintainable for long-running projects with complex UI, large code base and large team If this is not the case for your project (the screen is simple, and you are not going to add unit tests to the UI layer), it is best to:

>Use another more lightweight presentation technology (such as spring MVC). > Or simplify your policy (for example, allow presenters – > to view interactions without an interface) Typically, in this case, you cannot unit test the presenter As @ Andrea Boscolo mentioned, you can use gwtmockito as a solution to this problem!

Two other advantages of the interface between the view and the Presenter:

>You can easily switch the view implementation (about the famous case of making desctop UI – > mobile UI switching, unfortunately I have never seen the implementation) > for me, this is an obstacle to keep the presentation logic in the presenter The presenter knows only what is necessary I like the concept This helps me write all my works in the right place

The real meaning of all these files is that setting up an activity takes a long time To simplify it:

>Make sure to use the uibinder template in eclipse > more importantly, you can write a code generator, take the activity name and package as parameters, and then it will generate everything necessary Therefore, you just need to modify the activity mapper and start writing important UI logic It completes my current project and makes me very happy

Another source of templates is data binding Consider using the editor framework

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>