⚠️ This post links to an external website. ⚠️
I second guess myself a lot about what I know, or what I think I know. It’s even worse when it comes to the names of people I don’t normally interact with: “I’m almost positive his name is Dave, but I don’t want to get it wrong, so I’ll just wait until someone else says his name.” It’s a solution, but I’d rather be certain about their names.
In my previous article, Crawling the Web with Elixir’s Broadway and Wallaby, I suggested that it might be “beneficial to use either a Protocol or Behaviour to reduce code duplication,” but when considering which to use for what I’m working on, it left me second-guessing myself yet again. What’s the difference? When would you use one over the other? How do they actually help?
Because I don’t think I’m alone in my confusion, I’m going to try to answer these questions by first explaining what I thought I understood about both, talking about what I got wrong, showing the differences, and then giving a real-world—if contrived and incomplete—example for when you might use both.
continue reading on samuelmullen.com
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.