Skip to content
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

Initial commit. #1380

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Wojtek-A-JAVA
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your hard work on the SalaryInfo.java implementation! 😊 While your solution is on the right track, there are a few critical issues that need to be addressed to meet the task requirements.

  1. Date Handling: The use of Calendar and SimpleDateFormat should be replaced with LocalDate and DateTimeFormatter. This change is crucial as it aligns with modern Java practices and enhances code readability and maintainability.

  2. Constant Field for Formatter: The SimpleDateFormat instance should be declared as a constant field. This will improve the maintainability of your code.

  3. Inclusive Date Range: Ensure that the date range is inclusive as per the task requirements. The current approach of adjusting dates might lead to incorrect results.

  4. Redundant Loops and Magic Numbers: Consider optimizing your code by reducing redundant loops and replacing magic numbers with named constants for clarity.

Once these issues are resolved, your code will be much stronger and aligned with best practices. Keep up the great work, and I'm confident you'll nail it with these adjustments! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Great job on improving the SalaryInfo.java implementation! 🎉 Your use of LocalDate and DateTimeFormatter is spot on, and you've effectively handled the date range inclusively. However, there are a few critical points to address:

  1. Constant Field for Formatter: The DateTimeFormatter should be declared as a constant field to enhance code maintainability and readability. Consider defining it as private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT); at the class level.

  2. Date Range Inclusivity: Ensure the date range check is inclusive by using !isBefore(dateFromDateFormat) and !isAfter(dateToDateFormat) instead of adjusting the dates with minusDays and plusDays.

  3. Unnecessary DAY Constant: The DAY constant is incorrectly defined and is not necessary for the logic. Removing it will help avoid confusion.

Despite these issues, your code meets the task requirements and constraints. The decision to approve is made to help you move forward with your learning. Please review the comments to improve your code. Addressing these critical issues in the future will help you avoid similar problems. Keep up the great work and continue learning from your experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

private static final int NAME = 1;
private static final int HOURS = 2;
private static final int INCOME = 3;
private static final int DAY = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DAY constant is incorrectly defined as 1. This constant is not necessary for the logic and should be removed to avoid confusion.

for (String dataRow : data) {
String[] dataInfo = dataRow.split(" ");
if (changeDateFormat(dataInfo[DATE]).isAfter(dateFromDateFormat.minusDays(DAY))
&& changeDateFormat(dataInfo[DATE]).isBefore(dateToDateFormat.plusDays(DAY))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date range check should ensure inclusivity by using !isBefore(dateFromDateFormat) and !isAfter(dateToDateFormat) instead of adjusting the dates with minusDays and plusDays.

}

public LocalDate changeDateFormat(String stringDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DateTimeFormatter instance should be declared as a constant field to improve code maintainability. Consider defining it as private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT); at the class level.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AI is right, it's better to have this DateTimeFormatter as a constant field of the class.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link

@George-Khomiak George-Khomiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, created a few nice constants and the logic looks fine. Left a few comments for improvement though. Also, that would be nice if instead of having this huge one method you'd refactor it so it has some helper functions, but don't spend too much time on it, I'll accept the task once comments are resolved anyways. So don't think for too long on method refactoring.

}
}

StringBuilder stringBuilder = new StringBuilder("Report for period " + dateFrom

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringBuilder is not an informative name for a variable, it's the name of the class that creates this instance.

src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
}

public LocalDate changeDateFormat(String stringDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AI is right, it's better to have this DateTimeFormatter as a constant field of the class.

src/main/java/core/basesyntax/SalaryInfo.java Outdated Show resolved Hide resolved
}

public LocalDate changeDateFormat(String stringDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants