Skip to content

fix: adds exception handling to files under the ecommerce folder for lesson_14 homework - Joseph Caballero #454

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

Closed

Conversation

Josephcabs
Copy link
Contributor

Added exception handling to files under the ecommerce folder for lesson_14 homework.

…rors and seeking them in the right area. Lessons_14 ecommerce folder - Joseph Caballero
…ur specific application. lesson_14 - Joseph Caballero
…rocess for lesson_14 EcommerceSystem.java - Joseph Caballero
* if the productId is matched up to the hashmap at all using get and if it doesnt exist then product will be null because no such key exists
* instead of trying to put it in every single instance we see an order id or product id our test cases check to see if the given
* input is even available for us to grab not if there is any input at all since that itself in my opinion would be front end and not us
* that would handle that sort of thing before it reaches this point
Copy link
Contributor

Choose a reason for hiding this comment

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

Think defensively. Don't assume that your consumers are always going to do the right thing. Throwing this exception will help consumers understand why the operation didn't work in case they did the wrong thing.

Order order = orders.get(orderId);
// Since order is set at this exact moment all we need to do is check if the given id is in the
Copy link
Contributor

Choose a reason for hiding this comment

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

Use proper casing, grammar, and punctuation for your comments. Also, use shorter sentences for clarity. More importantly, I'd suggest that the code is clear enough on its own, so adding it just makes your reader have to do more work.

In general, only add comments to explain something that isn't immediately obvious in the code and that can't be made any simpler by rewriting the code itself.

@Josephcabs Josephcabs deleted the feature/lesson_14 branch November 24, 2024 21:14
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.

2 participants