[erlang-questions] MyModule:start_link/? vs supervisor:start_link/3

Jesper Louis Andersen <>
Thu Sep 15 11:43:14 CEST 2016

On Tue, Sep 13, 2016 at 11:06 PM, Charles Shuller <
> wrote:

> Is there any advantage to specifying a custom start_link in the supervisor
> callback module?

It is often used to keep the "scope" of the calls consistent. If you have a
call to e.g., gen_server:call/2 which is not inside the module defining the
Module:handle_call/3 callback, then you are leaking information about the
implementation to the outside caller and if you wish to switch to
gen_statem later, you will have to find all call sites and change them.

The same could be said for a call to supervisor. By keeping it local to the
module, you encapsulate the information about the supervisor into a module
on its own and that information doesn't leak outside. Granted, it is rarer
you wish to switch a supervisor to something else, but I have had the need
for this a couple of times.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160915/6306e42c/attachment.html>

More information about the erlang-questions mailing list