Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top