it can be rephrased as "inheritance and function library"
for example, I would like to add a method to javax.servlet.http.HttpServletRequest that gives me the whole object, the getBody () method, which will read the body through the getReader method, just to give an example.
In other languages, such as ruby โโor javascript, you can add a method to a base class or even to a specific instance, but in java I see two options ...
public static String HttpServeletHelper.getBody (HttpServletRequest request)
the first approach is more object oriented and elegant, but it forces you to throw your object every time you need it, and somehow you have to tell jsp to use your class ...
the second approach is just a good old library of functions ... which may be good or bad depending on how you look at it ...
What pros / cons do you see in each approach, and which one is more recommended for this kind of situation?
source share