Refactor getServletPath() and getPathInfo() for Conciseness#1103
Refactor getServletPath() and getPathInfo() for Conciseness#1103noureldenashraf wants to merge 1 commit intovaadin:12.5from
Conversation
|
|
Concise is often in conflict with debuggability (since it becomes more difficult to place a breakpoint or e.g. temporary logging in the right place) and readability. In this case, the exact context of the clarifying comments are lost which makes any benefits questionable. |
|
I also notice the original description made a claim about saving memory. This is not true - the JIT compiler will treat both forms in exactly the same way. There's even a possibility that the suggested way will be slightly shower since it ends up calling the super method twice. |
| } else { | ||
| return super.getServletPath(); | ||
| } | ||
| return (super.getPathInfo() == null) ? super.getServletPath() : ""; |
There was a problem hiding this comment.
The proposed code seems to invert the original logic
There was a problem hiding this comment.
Right. Yet another case for my claim that readability trumps conciseness.



#Description
Refactored
getServletPath()andgetPathInfo()methods to use the ternary operatorinstead ofif-else. This change improves code conciseness while maintaining the same functionality.#Type of change
#Checklist
#Additional for
Featuretype of change#Rationale for Change