Hacker News new | ask | show | jobs
by delinka 2873 days ago
Providing a protocol with a default concrete implementation of the interface? That's not passing code review here.

Would I have caught the bug? Probably not. But it looks like bad form to me to provide that default implementation to Greeter, so please rewrite your code.

1 comments

I’m curious to know why... Looks like typical mixin pattern, no?
An interface declaration is not the right place for implementation. If you want a default implementation, use a base class and inherit, overriding if you don't want the default.

This bug is now another good reason not to use default implementations on interfaces.

Protocol extensions are extremely powerful and safe if used correctly and not mixed with class inheritance as in this example.
Ok, thanks. Sounds like you are not a fan of mixins! :)