I'd like to see something about situations where you would prefer to use protocols over behaviors, or vice-versa. This is a hard decision to make, but I think I've developed a preference for protocols.
In general, I've seen behaviours misused more than protocols, where a behaviour will expect a struct of the using module's type, basically re-creating protocols but without some compiler niceness. Passing around a module name and then calling a function on it always feels awkward. I'd rather call a function on a named module so I can make sure the function exists at compile-time. I think it's harder to misuse protocols, especially because I do think they would still work in a lot of situations where behaviours would.
Here are a few things I read about this subject which can make clear that it's a hard choice:
I would welcome a discussion; like I said this is a very nuanced decision where I think some advice would be very useful.
I'd like to see something about situations where you would prefer to use protocols over behaviors, or vice-versa. This is a hard decision to make, but I think I've developed a preference for protocols.
In general, I've seen behaviours misused more than protocols, where a behaviour will expect a struct of the using module's type, basically re-creating protocols but without some compiler niceness. Passing around a module name and then calling a function on it always feels awkward. I'd rather call a function on a named module so I can make sure the function exists at compile-time. I think it's harder to misuse protocols, especially because I do think they would still work in a lot of situations where behaviours would.
Here are a few things I read about this subject which can make clear that it's a hard choice:
I would welcome a discussion; like I said this is a very nuanced decision where I think some advice would be very useful.