-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1374
base: master
Are you sure you want to change the base?
Solution #1374
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check the common mistakes list and fix your solution by list ;)
private static final DateTimeFormatter DATE_FORMATTER = ( | ||
DateTimeFormatter.ofPattern("dd.MM.yyyy") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final DateTimeFormatter DATE_FORMATTER = ( | |
DateTimeFormatter.ofPattern("dd.MM.yyyy") | |
); | |
private static final DateTimeFormatter DATE_FORMATTER = | |
DateTimeFormatter.ofPattern("dd.MM.yyyy"); |
redundant brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a best practice in Java?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, don't complicate the code unnecessarily
return null; | ||
StringBuilder result = new StringBuilder( | ||
"Report for period " | ||
).append(dateFrom).append(" - ").append(dateTo).append("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create constant variables for all literals like HEADER, SEPARATOR, etc.
Use System.lineseparator instead of "\n"
if ( | ||
workerName.equals(name) && (date.isEqual(fromDate) | ||
|| date.isEqual(toDate) | ||
|| (date.isAfter(fromDate) && date.isBefore(toDate))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better move this conditional to the private method
result.append(name).append(" - ").append(salary).append("\n"); | ||
} | ||
|
||
return result.deleteCharAt(result.length() - 1).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think how you can avoid .deleteCharAt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! A few minor comments ;)
} | ||
result[i + 1] = name + SEPARATOR + salary; | ||
} | ||
return String.join("\n", result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return String.join("\n", result); | |
return String.join(System.lineseparator(), result); |
private static String HEADER = "Report for period "; | ||
private static String SEPARATOR = " - "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static String HEADER = "Report for period "; | |
private static String SEPARATOR = " - "; | |
private static final String HEADER = "Report for period "; | |
private static final String SEPARATOR = " - "; |
No description provided.