HttpServlet
is an abstract class with all implemented methods. Why it is abstract?
The most common answer I got is, to restrict the instantiation of HttpServlet
. But there are other ways of doing it, like a private constructor will restrict the instantiation.
I can understand that they are following Template Method design pattern. If some methods are abstract, user will end up implementing all of them, even if he does not need them for his business logic.
But if HttpServlet
was not abstract, an user can still extend it and override the require methods.
At least by the dictionary meaning of the word 'abstract', its does not make any sense to me to have a abstract class with all implemented method.
Yes a combination of abstract and concrete methods are ok to have.
But if you are making a class abstract why not make those methods abstract which the sub class has to override? or may be do not declare it as abstract at all?
Like doGet()
or doPost()
is this case.