Transparent / composed
The content of this article comes from various channels, with friends informal discussions and email exchanges, there are also various information on the Internet, as well as the practical experience of developers. In order to facilitate the readers, I don't have to take them into the form of dialogue, and borrow two fashionable characters (the old users of Webwork's enthusiasts, the old users of Struts, to compare these two popular web frameworks, hope to readers The choice is helpful.
Steven: Hey, Weber, what are you busy with?
Weber: Oh, I just made a project, do it with Webwork, I feel very good.
Steven: Webwork? I know it, what is it?
Weber: Benefits can be much better than Struts. Do you have Struts for so long? Don't you feel uncomfortable?
Steven: Well ... it does have some. For example, Struts's ActionForm is actually not very easy, it is a bit non-collar, and it is incoming trouble between Action and View. The most recent design of Struts has gradually diluted Actionform.
Weber: Yes. And the Struts is unhappy, and there is more ugly. Action must be inherited, and now have not changed to the interface inheritance. Moreover, the interface of the Execute method is also all httpservlet ..., you can't get off the servlet container, you have to test the request to provide MOCK.
Steven: Struts has to remove all status from the action, so you need to pass all status from the action, which is a typical stateless design, preparing for pool and load, theory The delay in performance should be better. Struts must be handled each time you have to process Request / Response, so you must provide some tool methods, so Action is no longer an interface, and it is changed to a Class, which is also commonly used in OOD. If there is no such interface, how do you pass data between servlets and anctions?
Weber: This is the WEBWORK design is wonderful. Action is a common JavaBean, which only implements its business function, other infrastructure-level features - For example, how to exchange data with servlet - all use interceptors. It is because of this interceptor mechanism, so webwork is so easy.
Steven: But I'm watching the functionality provided by Webwork or less. For example, it doesn't have the ability to verify the ability, you must use other tools to help check.
Weber: Yes, but this feature can be done with interceptor mechanisms, you can abstract these interceptors to be reused. So the webwork itself does not need to include that complete features, it only provides a flexible core, and many features can be plugged in. Struts is more troublesome, and new features will hurt the bones, so Struts always has a lot of new features to be released.
Steven: Yes. Recent Struts released the message, future versions will increase support to JSR-168 portlets.
Weber: This issue is not a problem in Webwork. As long as you do a portlet as the engine, modify a few configurations, all WebWork Actions can be placed to the portlet environment, because they are originally the most ordinary Javabean, do not know the outside environment is a servlet environment or portlet. surroundings. Since the Action does not rely on a specific operating environment, the unit test is also very convenient, directly put the action new, and set the parameters to you. Steven: Speaking of the test, do not say the first area, do not say, at least 1/3 of the software company is in the stage of TDD? Is there 1/3 of the company's development method of CMM and some waterfall models? Then, for these companies, Struts and Webwork are unpredictable differences. In the current state, easy-to-test is not a key target for software enterprise technology selection, then Struts has its survive soil. Of course, this is a bit far away.
Weber: You are very reasonable. Struts is better than people support, use, make people feel stable, insurance, and guarantee. If you do a project, many bosses must say that I want new technologies, it is stable. So now I am still often using the struts development project.
Steven: It seems that I should know more about Webwork. If the development method of TDD will be used in the future, it is indeed important factor, and maybe I will choose Webwork.
Weber: There is another way to transform Struts, add interceptor mechanism, then use the interceptor to implement the Dependency Injection, so you can make Struts easy to use as Webwork, and will not lose it The original features are not complicated.
Steven: It is really good. In this way, there is another optional solution in my toolbox.
Appendix: About the technical comparison between Struts and WebWork, please see the following two addresses: http://udoo.51.net/mt/archives/000044.htmlhttp: //wiki.opensymphony.com/display/wwclarison TO STRUTS