質問

I'm modeling a web application, which has some HTML pages, javascript files and 6 servlets.

Right now I have all the servlets in separate classes, but they all share the same methods (doPost, doGet, processRequest, with different implementations) and all of them have the <servlet> stereotype.

I was wondering if there is a way to represent all of them with one class. I'm going to do a text to describe the diagram, so maybe I can explain what that class represents.

役に立ちましたか?

解決

As all the methods you cite (doPost, doGet, processRequest) seem to be inherited from Java's HttpServlet, you may as well represent all the implementations with their common parent class HttpServlet.

他のヒント

If the design goes ahead of implementation, I would suggest you create an interface with the common methods(doPost, doGet, processRequest); then different classes implement the same interface. You can optionally introduce an class with default implementation of the interface and let your classes generalize from this class.

If the implementation was already there, to be honest, it is not well designed. A refactor will be much better.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top