tags:

views:

55

answers:

1

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).
 -behavior(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()).

+4  A: 

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.

thenduks
Exactly. You can treat behaviors the same way as interfaces in the OO world.
Zed
That's what I thought myself but wanted to check with a more knowledgeable crowd. Thanks guys!
jldupont