Your ctor says that your code is headache inducing: Explanation
Join the DZone community and get the full member experience.
Join For Freei was pointed to this codebase , as a good candidate for review. as usual, i have no contact with the project owners, and i am merely using the code as a good way to discuss architecture and patterns.
it starts with this class:
okay, this codebase is going to have the following problems:
- complex and complicated
- hard to maintain
- hard to test
- probably contains a lot of code “best practices” that are going to cause a lot of pain
and i said that this is the case without looking at any part of the code except for this constructor. how am i so certain of that?
put simply, with 9 dependencies, and especially with those kind of dependencies, i can pretty much ensure that this class already violate the single responsibility principle. it is just doing too much, too complex and too fragile.
i shudder to think what is involved in testing something like that. now, to be fair, i looked at the rest of the codebase, and it seems like i caught it in a state of flux, with a lot of stuff still not implemented.
nevertheless… this is a recipe for disaster, and i should know, i have gone ctor happy more than once, and i learned from it.
and here is the obligatory self reference:
and yes, this does give me a headache, too.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments