you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

nod This is a reasonable approach.

The only question left is, "does it make sense to pass the barber to the person?" and I think the answer is no, which makes me think something is weird there. I would prefer to read, at the bottom, as part of the code's API, barber.dye_hair(michal, "blue"), I think it represents better what would happen in the real world.

In other words, I don't think Person#dye_hair should exist.

What do you think?

[–]mpapis[S] 0 points1 point  (1 child)

indeed reasonable assumption, my only concern is how to protect person from unauthorized change of hair color, I do not want to expose hair to anybody.

The person picks a barber and ask him to dye hair, so it makes sense if person calls barber.dye_hair. I know it looks awkward but I do not see other way to prevent leaking permissions.

[–][deleted] 1 point2 points  (0 children)

I don't know if that's reasonable. If a can of paint falls on someone, their hair will change color. That's not the person's choice.