You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This anti-pattern manifests when a package author or a library defines modules outside of its "namespace". A library should use its name as a "prefix" for all of its modules. For example, a package named :my_lib should define all of its modules within the MyLib namespace, such as MyLib.User, MyLib.SubModule, MyLib.Application, and MyLib itself.
This suggests that the "namespace" should be something like RiotLoR. There isn't an official Riot namespace, but I do not wish to claim it. I'd rather keep that namespace open and have my own, distinct, namespace. This is based on this example:
Even if Plug does not currently define a Plug.Auth module, it may add such a module in the future, which would ultimately conflict with plug_auth's definition.
Further, this library is specific to Runeterra, i.e. the LoR. However, if I choose to extend my development to something beyond Runeterra, RiotLoR isn't a great prefix. So, based on this example:
If you are the maintainer for both plug and plug_auth, then you may allow plug_auth to define modules with the Plug namespace, such as Plug.Auth. However, you are responsible for avoiding or managing any conflicts that may arise in the future
It may be prudent to come up with a common, more generic, prefix.
E.g. say I have to libraries: one for Runeterra deckcodes and one for the Riot API. I may desire to have a common prefix, say MyRiotLib. I can then have a common prefix across libraries, i.e. MyRiotLib.Runeterra and MyRiotLib.API.
MyRiotLib is not an app reference itself, but can be a common prefix, like Plug. The respective app names may be something like :myriotlib_runeterra and :myriotlib_api
This is a major change and will require a major version update. Further, there may be implications of changing the app name for Hex
The text was updated successfully, but these errors were encountered:
The app name is
:riot_lor
; however, our "root" module isRiot
.According to https://hexdocs.pm/elixir/main/code-anti-patterns.html#namespace-trespassing this may be considered "namespace trespassing"
This suggests that the "namespace" should be something like
RiotLoR
. There isn't an officialRiot
namespace, but I do not wish to claim it. I'd rather keep that namespace open and have my own, distinct, namespace. This is based on this example:Further, this library is specific to Runeterra, i.e. the
LoR
. However, if I choose to extend my development to something beyond Runeterra,RiotLoR
isn't a great prefix. So, based on this example:It may be prudent to come up with a common, more generic, prefix.
E.g. say I have to libraries: one for Runeterra deckcodes and one for the Riot API. I may desire to have a common prefix, say
MyRiotLib
. I can then have a common prefix across libraries, i.e.MyRiotLib.Runeterra
andMyRiotLib.API
.MyRiotLib
is not an app reference itself, but can be a common prefix, likePlug
. The respective app names may be something like:myriotlib_runeterra
and:myriotlib_api
This is a major change and will require a major version update. Further, there may be implications of changing the app name for Hex
The text was updated successfully, but these errors were encountered: