google / google/auto

Why @Provided instead of @Assisted?

Open
#215 0 comments 1 reaction 0 assignees View on GitHub
Component: factory P3 type=documentation
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

This isn't really a bug as much as a design question. as far as i am aware @AutoFactory was designed as a more performant alternative to guices assisted-inject extension, so i am curious why in @AutoFactory you annotate all the parameters that you want to be injected whereas in guice you annotate all the parameters that should be explicitly passed (with @Assisted).

I have a (mild) preference for the @Assisted approach since
1. in my experience, there are are fewer @Assisted params than @Provided params
2. the provided params will often already have @Qualifier annotations applied to them, so adding @Provided adds more noise to the parameter declaration (plus raises unfortunate questions about annotation ordering)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.