Closed lutzseverino closed 1 year ago
Created a draft to ask the following.
The BaseDAO
contains a piece of code that is repeated 3 times.
if (cursorString != null && !cursorString.trim().equalsIgnoreCase(Constants.ALL_RESULTS)) {
Cursor cursor = Cursor.fromWebSafeString(cursorString);
Map<String, Object> extensionMap = new HashMap<>();
extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
query.setExtensions(extensionMap);
}
If it were to be extracted, what would be an appropriate method name?
Code quality and readability review
This PR contains certain quality improvements that don't tackle on changing the approach, but rather readability.
Problem
Code clarity and readability could be improved upon on some parts of the code I'm going to work on.
Solution
Automatically format with the IDE, cleanup the logic, and many other micro-improvements that make the code more readable and of better quality overall.
Examples
Use of ternary operators
This logic may be unnecessary or overcomplicated, but I'm not worrying about that right now.
Replacing that with a ternary one-liner improves readability and makes it easier for a future contributor to apply a different approach or verify this one.
Switches
If-else chains to switches…
Line-breaks
And convenient line-breaks for a massive readability boost.
Extract repeated code
Additionally, some code repetition was present and removed. Not everywhere though, some instances were not worth to change due to possible changes in the future. This logic was present several times, including the
#getTime
call. This can all be effectively abstracted.A new approach may still be desired, but once again, that's not what I'm focusing on right