Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we introduce @Newable / @Injectable? #5

Open
odrotbohm opened this issue Feb 7, 2020 · 0 comments
Open

Should we introduce @Newable / @Injectable? #5

odrotbohm opened this issue Feb 7, 2020 · 0 comments

Comments

@odrotbohm
Copy link
Member

In their implementations, DDD building blocks have a well defined mapping towards who is managing the lifecycle of them. Two concepts can be found:

  • Newables – concepts manually instantiated in domain code either via constructors or factory methods. Building blocks that fall into that category: value objects, entities, aggregates.
  • Injectables – concepts instantiated and assembled in a canonical place (either by hand crafted code or some kind of container managing the object lifecycle). Those are usually wired into through the concept of dependency injection (hence the name). Building blocks to mention here: factory, repository, service.

The annotations here would be defined as meta-annotations (i.e. @Target(ElementType.ANNOTATION_TYPE)) only as they're used to qualify meta elements for either references. A downstream use case would be for tools to easily identify the different groups of concepts so that they can define general rules enforced on those without having to know about which of the actual meta elements belong to that group. A very fundamental rule example would be that newables must not depend on injectables but only the other way round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant