0

Coming up on this discussion - https://softwareengineering.stackexchange.com/a/271585/53263

Because I'm trying to avoid this problem - Are answers being posted as comments?

My answer is reproduced here, less the OP's original quote:

Wow! We do not work on the same code bases.

Inversion of Control frameworks - like Guice or Spring - essentially strive to make this half of your problem, a pillar of design. Many arguments in constructors is totally fine.

Seriously, a typical constructor in my code base might have 20+ arguments. No apologies.

I have delete votes for this. I feel this is wrong because:

  • people should be allowed to answer questions...
  • incompletely because they have something substantive to say but don't have the desire for whatever reason to write something extensive...
  • letting others write better answers to flesh out the response if possible...
  • because an incomplete answer such as mine may be extremely helpful to the OP and future visitors...
  • and answer as an answer since the comment muck is not appropriate for what is, in fact, an answer.

I'm disappointed I have delete votes and downvotes for what seems to be incompleteness alone, and want to see what meta thinks.

1

1 Answer 1

2

It's not incomplete. How does it answer the question?

The question is: "How does one keep argument counts low and still keep third party dependencies separate?" The bulk of your answer is talking about your codebase and how you allow for large numbers of arguments to constructors. An answer of "you don't need to" with sufficient explanation for why it's not a concern would be OK, but only one line of your answer deals with methods for minimizing the impact of large constructors. Maybe if you expanded on that part and removed the commentary, it would be OK.

5
  • The XY problem. Should I be more explicit that the OP is asking the wrong questions and many constructor args are okay if one uses the proper framework? Then it will be an incomplete answer and if someone else wants to explain how these frameworks make it into less of a problem they can.
    – djechlin
    Feb 20, 2015 at 17:01
  • @djechlin You need to actually explain why the solution the asker is looking for doesn't work for it to be a good answer and present details about what the right solutions may be. Your answer effectively says "Inversion of Control frameworks make this problem not a problem and allow for large numbers of arguments in the constructor." That's nice, but you need more details than that. Are there other drawbacks with IoC containers? What would the design look like if you used IoC containers? Details are crucial, and we expect answers to have those details.
    – Thomas Owens Mod
    Feb 20, 2015 at 17:03
  • Any problem with a not-that-useful but not harmful answer appearing 2/3 down the page since it's not highly upvoted? and with important keywords/concepts introduced that other answers don't?
    – djechlin
    Feb 20, 2015 at 17:10
  • 1
    @djechlin FWIW in active tab view, the answer is not "2/3 down the page" but second from top. And it obscures three prior answers that seem to be better to the readers, given their score. Reasoning about low score posts at bottom may fly by SE mgmt who bend over to web search visitors using default sort by votes, but not by site regulars who reviewed this post
    – gnat
    Feb 20, 2015 at 17:33
  • All right, consider writing up an explanation for how modern IoC-based development favors heavy constructors since none of the answers are really in the right direction.
    – djechlin
    Feb 20, 2015 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .