Q: I'd like to have an idea of the pros and cons of defining multiple behaviors in the same module file.
E.g.
-module(someapp_sup).
-behavi开发者_JS百科or(supervisor).
-behavior(application).
Using this sort of layout, I can save a module file whilst not loosing much on the maintainability side (the whole application is started through someapp_sup:start()
).
As long as the callbacks defined in the behavior don't conflict with a callback of another behavior (say you defined your own behavior, for example) then there's nothing wrong with doing this other than potentially more confusing code. Obviously you can curb that with some well placed comments and laying the code out sensibly in the file.
精彩评论