Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
implemented fruit shop program logic using solid principles #1292
base: master
Are you sure you want to change the base?
implemented fruit shop program logic using solid principles #1292
Changes from 4 commits
9c9e0b4
dac23fa
10ebf10
e830cb2
a12a686
032eb85
49e39f5
ee9f43e
142296e
71a9138
c19eee1
b0dd1dd
06aa862
b977aa7
dfec118
31644a0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
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.
Direct instantiation of
Storage
might expose its internal state. Consider using a method to access its data to maintain encapsulation.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.
the same
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.
Returning a new
HashMap
ingetAllFruits
is a good practice for encapsulation, as it prevents external modification of the internal map.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.
fix comment
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.
The
parseCsvRow
method might not belong in theFileReader
interface, as it deals with parsing rather than reading files. Consider moving this method to a more appropriate class or interface, such asDataConverter
.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.
Parsing
fields[2]
to an integer can throw aNumberFormatException
if the input is not a valid integer. Consider adding a try-catch block to handle this exception and provide a more informative error message.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.
Consider logging the error or adding a comment to explain why an
IllegalArgumentException
is thrown for an unknown operation code. This can help with debugging and understanding the code's behavior.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.
leave only one empty line
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.
The error message for
Invalid quantity format
is informative, but consider including the row number or more context to aid in debugging when this exception is thrown.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.
The
parseCsvRow
method is responsible for parsing CSV rows intoFruitTransaction
objects, which is not directly related to file reading. Consider moving this method to a class that handles data conversion, such asDataConverterImpl
, to improve separation of concerns.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.
add writing logic
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.
The constructor in
FileWriterImpl
is redundant as it doesn't add any new functionality beyond whatFileWriter
already provides. Consider removing it unless you plan to extend its functionality.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.
The constructor in
FileWriterImpl
is redundant as it does not add any new functionality beyond calling the superclass constructor. Consider removing it unless you plan to add additional functionality.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.
the same
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.
The
get
method may return null if the operation type is not found in the map. Consider handling this case by returning a default handler, throwing an exception, or providing a meaningful error message to avoid potentialNullPointerException
.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.
The
operationStrategy.get
method may return null if no handler is found for a given operation. Consider adding a null check and handling this case to prevent potentialNullPointerException
.