rewe-digital/katana

Rename singleton

Closed this issue · 5 comments

Think about renaming singleton inside Module. The name might be misleading to some users as a singleton in Katana is related to a Component. There only exist one instance per component and not as some might think per application.

What would be a better name?

  • scoped
  • componentScoped
  • componentSingleton

scoped

Maybe rename Module instead in a way that it's clear that it doesn't contain instances?

Maybe ModuleDeclaration or something?

I'm not really sure if renaming Module is a solution. I actually like the name and the concept of modules and components should be clear from other DI frameworks like Dagger.

I prefer scoped. What if we keep singleton as an alias to scoped?

Dagger also declares Singletons in their modules and only saves them in components (although there aren't multiple components like in Katana... so @Singleton or @ActivityScope, etc... is the real indicator of what happens), so that's also a concept that's clear for those coming from there... In a sense, in Dagger a Singleton is just another type of scoped value though, and users can make their own, so the distinction between singleton and scoped is required there. In Katana, the scope is really managed by multiple components.

That said, if singleton is left around, it doesn't really matter to me if there's also scoped 😄, I'm personally more used to singleton...