-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
Error encapsulation #2080
Error encapsulation #2080
Conversation
The exercise that follows this document asks to encapsulate one error, but not any others. Both the knowledge of how to encapsulate, as well as that it is a requirement seemed absent to me.
Dear Lewiscowles1986Thank you for contributing to the Go track on Exercism! 💙
Dear Reviewer/Maintainer
Automated comment created by PR Commenter 🤖. |
If acceptable to exercism; I can squash the commits. I was using exercism on the web and decided to stay in the web, where I'm not aware of squash or commit amend functionality. |
Hi, Thanks for the PR. In my opinion, this PR doesn't add much, and I'm having some issues trying to see what a student might get from this. My first issue is with the term "encapsulation". For me, encapsulation means hiding implementation details by only exposing behavior, which ideally is detached from a concrete implementation and I don't see how it applies here. I find the description to be a bit vague by not providing a concrete example on how this can be useful. The description tries to sell the idea that we must check for a particular error and do something else with it other than returning it. My question when reading this is: ok, so what should we do instead? By not providing a concrete example of that "something else" we should do with the error, In the example from the "Checking for Errors" section of this file, we already provide an example on how to do something else when the error is of a particular error and I'm failing to see how this is different. I think you are trying to introduce the student to the concept that we can check for certain error types and do something different with them based on its type, and I think that's why you are comparing them to exceptions. However, this topic is probably a better fit for the Error Wrapping concept where we can properly introduce the student to error type checking.
In your branch, it's personal choice whether you create several commits or squash/amend them to make sure it all fits into just one. When merging, we squash all the commits, so all PR's end up being just 1 commit regardless. |
Hi. Thanks for taking the time to review and give such volumous feedback.
The wish/intent is for a student to understand a thing they will be asked to do in the task which covers errors as a concept, which I believe was not explained enough for new learners. In that task, a specific type of error is encapsulated and hidden within the task; which does not mention to forward all errors, but one; but readily requires it as far as I can see.
My apologies for failing to capture the use of this. My attempt was to give enough information, without doing the work for the learner. As I have before, and I am sure I will again, I clearly failed to convey this:
To my mind, the only reasons not to forward an error to a user, are to:
I did not wrap the error, by passing it to the error format using Can you think of other reasons this is a useful pattern? I Too am always trying to learn new things 😉. In any case. I Can accept this isn't what is needed, but I might need some help to improve it. Alternatively if nobody has time, I am happy to close this, as I accept from your comments; it's not quite enough, but don't think I can think of a clearer, more concise explanation; than I've provided. Best |
Just as @andrerfcsantos, I also think "Encapsulation" and the coding pattern shown in this PR are two separate concerns. For example, in the following code, there is no encapsulation happening.
Encapsulation should be discussed in the error wrapping concept. Putting that aside, the other question remains whether or not we want to present the pattern of "returning for all but one specific error" ( So I would vote for closing this PR and having a discussion about changing the exercise so that the student does not have to work with a result of a function even though there was an error. (I will leave a comment about this in #2011.) |
@Lewiscowles1986 I see. Then you are right in making a PR like this one, as the introduction must indeed have everything the student needs to solve the exercise. However, like @junedev suggested in #2011, I also agree that instead of adding this to the description, we should just change the exercise so it doesn't need this. For this reason I'll close this PR and forward further discussion to #2011. Many thanks @Lewiscowles1986 for bringing this to our attention! |
Part 1 of addressing #2011
The exercise that follows this document asks to encapsulate one error, but not any others.
Both the knowledge of how to encapsulate, as well as that it is a requirement seemed absent to me.