What is the best way of coding DWR based classes?
What is the best way to code DWR (Direct Web Remoting - Ajax for Java) based log开发者_开发知识库ic in a web application? I have listed 3 types of disciplines.
Use of single class to code DWR based implementations
eg: For all scenarios use DWRUtil.java (contains all logic related to several actions in many pages, for example Order placing related Ajax calls, customer registration related Ajax calls)Use separate DWR based class for each scenario(there can be several JSPs sharing same java script generated by DWR)
eg: For customer registration - CustomerRegisterUtil.java, for order processing utility methods - OrderProcessUtil.javaUse separate DWR based class for each page
eg: For customer registration page- CustomerRegisterUtil.java, for order processing page - OrderProcessUtil.java
The answer depends on your project. In my opinion, you should split up your DWR classes in such a way that it's obvious to developers which class contains which functionality.
So if you have very few DWR calls, put them in the one DWR class. Other developers will then know exactly where to go for all DWR code.
But for most projects you'll need quite a number of calls, so putting them in one file will make them hard to find. Then it's up to you to split them up in an appropriate way. You'll probably find that creating one DWR class for each scenario is the best, rather than one per page. That's because a particular DWR method might be useful on a number of pages, so all the pages in that scenario can use the one method.
精彩评论