-
-
Notifications
You must be signed in to change notification settings - Fork 551
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
Allergies READ ME needs clarification #224
Comments
It's not cycle but ceiling. I think scores higher than 255 should be treated as invalid inputs--the system can't interpret those as allergies. Cycling means making a presumption about all larger values. If you add allergy to a cyclical system you will have invalidated all previous interpretations of values greater than the max. |
If you interpret these as bitmasks, then it doesn't matter that the number is higher than 256. Either the bit is flipped or it's not. |
Also ceiling is also a presumption: 256 == 255. I'm on the fence about "fixing" this design. An advanced exercise could be dealing with the fallout of the current implementation, a body of accumulated data, and the requirement of adding additional allergies. |
Right 0-255 would be the valid range. |
The mask could be seen as the floor problem: 256 == 0. That would be problematic in the same way. Sometimes you just need I think of a school importing transfer students data, whose allergy scores are based on a different system. If they can't translate a given score, they probably shouldn't enter apparently valid score from the system they have. |
The cyclical solution is the one that passes the tests in Elm. I'd rather treat values larger than 255 as invalid and error out or return nil or Nothing (in the case of Elm) if that's the way you're leaning. But this will fail current tests at least in Elm. Sent from my mobile.
|
That's a good point. Once we decide on an approach or a fix, we should:
|
An interesting perspective was brought up by one of the participants in my Kata group. The student has food allergies, and he values false positives more than false negatives (i.e., he'd rather be told, incorrectly, that he's allergic to tomatoes than be told, incorrectly, that he's not). So his implementation of this exercise was to default everything to true. If the system got invalid input, it would say that the patient was allergic to everything. |
That's really, really interesting—and could save lives. |
If the system gains a reputation for false positives, it stops being trusted and stops being used. |
I think I've pushed us from discussing the problem as a learning exercise and into discussing a real world implementation. My fault. The problem, as I understand it, is what to do with values greater than 255, right? I think it depends on what you're trying to teach. If the problem is meant to teach about bitwise operators (and nearly every solution I've seen uses bitwise operators), then you should have a test that shows off the benefits of bitwise. Either testing the score 257 or 509 work for me, but I don't think you need both. If you want to focus the problem on handling correct values, then have a test that results in errors for values outside of 0..255. |
The thing about these higher numbers, though, is that all of the defined bits are still valid, it's just that we don't have any definitions for the higher-value bits. So the input isn't garbage, per se. I recently worked on a configuration/subscription system that used a bitmask and we didn't care what the input value was, only whether the bits we cared about were flipped or not. That said, I'm fine with changing this to be errors outside of the defined range. |
I think expecting (and testing for) normal bitwise implementations makes sense. So, either a test for 257 or 509 (or whatever). But only one, since that's enough to cover the thing that you're trying to test. |
Agreed, one should be enough. |
I'm also strongly in favor of the "bitwise" interpretation. The actual value of the number passed in does not matter, as long as the correct bits are set. I think |
Agreed, but restricted to positive numbers, of course! 😄 |
Haha, yes, absolutely! |
Any reason to keep this still open after #389 was merged? |
I think it is safe to close. |
Hi There are three ways to interpret the Allergies problem with regards to large scores. Below are the options. The first one passes the test in Elm-lang but seems incorrect to me. The second seems correct but fails the tests. And the third is possible but tests should catch it better.
If the score is >= 256 then
So following the first case a score of 257 equals a score of 1 since 257 - 256 is 1. This doesn't seem right to me, but if it is right then it should be stated in the Read Me.
The second is the one the READ ME alludes to but the tests fail.
Which is the way this should go? Should we clarify the READ ME with:
Or do we need to updated the tests and the READ ME with:
The text was updated successfully, but these errors were encountered: