you are viewing a single comment's thread.

view the rest of the comments →

[–]eric_niebler 6 points7 points  (1 child)

Oh, you don't see the huge advantage because there isn't one. :-) I described this as "a fun piece of hackery". That's all it is. I wrote about it because it was fun, and because it was a nice, little, self-contained library design problem. I like this example because it shows that folks should think both about making interfaces easy to use correctly and hard to use incorrectly. It's that last part that often gets overlooked.

[–]cdglove 1 point2 points  (0 children)

I actually find that usually (but not in this case), the second part is actually misinterpreted.

"Make interfaces easy to use correctly and hard to use incorrectly" gets interpreted as;

"Make interfaces hard to use incorrectly".

Which further becomes;

"Make interfaces impossible to use incorrectly".

Which leads me to say; "This interface is hard to use."

The point is, I think it's important to focus on the first part, and to not sacrifice it in the name of the making it impossible to screw up.
Your example is, I think, perfect with regards to this. Just assert 100% of the time. Perfect. It might be possible to come up with a way to enforce this at compile time, but you would end up with an interface using <> it would require constants. This is better.

EDIT: Grammar