0

I have a controller which takes care of a user's first time journey at my website (ignore names of below dependencies, they are random)

@RestController
class Controller(
        private val fooComponent: FooComponent,
        private val dataComponent: DataComponent,
        private val userComponent: UserComponent,
        private val restComponent: RestComponent,
        private val calcComponent: CalcComponent,
        private val studentComponent: StudentComponent,
        private val tampComponent: TampComponent,
        private val checkComponent: CheckComponent,
        private val trialComponent: TrialComponent,
        private val reviewComponent: ReviewComponent,
        private val helpComponent: HelpComponent,
        private val achievementComponent: AchievementComponent,
        private val glassComponent: GlassComponent
) 

As you can see, it has a lot of dependencies . It's usually accepted that a lot of dependencies mean the code is violating the Single-responsibility principle. Here, this controller takes care of one user journey( like registration to my website). what are the other downsides for this design? Also, Would appreciate suggestions for alternatives.

Shashank
  • 166
  • 1
  • 2
  • 12
  • 1
    Does this answer your question? [How many constructor arguments is too many?](https://stackoverflow.com/questions/40264/how-many-constructor-arguments-is-too-many) – Arvind Kumar Avinash May 23 '20 at 22:00
  • Are you intending the parameters to be `@Autowired`?  You haven't marked the as such, but that's a fairly common pattern for them, and it would probably affect the answer. – gidds May 23 '20 at 22:16
  • 1
    Yes, @Autowired annotation is not needed anymore in spring latest release. – Shashank May 23 '20 at 22:32

0 Answers0