开发者

Erlang: multiple behaviors defined in the same module?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜