mariocasciaro / scatter

IoC container and out-of-the-box extensibility for Node.js applications
MIT License
154 stars 14 forks source link

May service namespaces be arbitrary? #22

Closed k7sleeper closed 10 years ago

k7sleeper commented 10 years ago

Given a module a/b/c/module1. Is it allowed for module1 to provide a service app/setUp or must the provided service namespace be a substring of a/b/c/module1?

Is it also allowed to have an empty service namespace?

mariocasciaro commented 10 years ago

Correct, the providing module must be inside the service namespace (or subnamespace). So yes, you can define a service without any namespace, in this case any module can provide it. But I would avoid to do that unless it's really necessary, service namespacing was created to enhance readability of the code (you know straight away where to find all the modules providing a namespace) and performances (scatter only needs to load/scan a namespace to invoke the service).