7

In evaluating the work of an outsourcing company, I have found that they have a propensity for dividing work into as many classes as possible, each one being testable. In some ways this seems commendable, but they are taking it to an extreme and no one seems able to control them.

Recently I found what should have been a simple UI piece that I would have implemented as at most 3 classes (one for data, one for controller, one for view), they had in fact broken up into some 20 classes (e.g. base class and multiple derived classes) and protocols, requiring in the end about 70 source files (Objective C .m files and .h headers) which included a test for each and every part, even the tiniest piece. Their code, despite the elaborate testing code, barely works and is constantly breaking.

They justify this with vague talk about SOLID and/or the "massive class" problem.

This code is already written. No one but them was allowed to design it. I can criticize implementation, but not really influence design.

So what is a good strategy, other than seeking better employment, for dealing with Outsourcing Companies Gone Wild where their numerous engineers expand simple projects as much as possible and as long as possible in this way, rendering them complicated and vast?

Questio
  • 89
  • 1

4 Answers4

8

Given problem x how can I say 20 is wrong and 3 is right?

Here's how:

On a good day my brain can hold 7 things at a time. That's it. No more. Sometimes it's only 5.

So 20 is to much. Don't care what x is.

However, 4 abstractions with 5 classes hiding behind each is fine. And yeah. That is still 20. Likely more.

What I'm saying is the numbers matter but so does the organization. If these guys are going nuts with small classes but doing nothing to organize them then they're causing a real problem. It's not just that you're not used to the style. It's that they're asking you to remember more than 7 things at once.

This is a valid style. Be careful not to come off as simply against it. Instead emphasize the need for trustworthy abstractions to improve readability. If you have to dive into an abstraction to understand it, it's not working.

They decided to break things down this small. It's on them to put it all together in a way that makes sense.

candied_orange
  • 119,268
2

Without see the code is hard to tell if they are doing a good or bad job.

But normally is a good idea break the code in tiny classes. This strategy is very common when you are not sure about the better organization of the code: what classes you really need, how they will be organized, the domain knowledge is not good yet, etc.

Maybe you can argue something in this line to convince the rest of the team that some classes makes more sense to be only one class now. There is an article about that by Martin Fowler .

Their code, despite the elaborate testing code, barely works and is constantly breaking.

This is not necessarily a problem from the tiny classes strategy. Maybe the project need some integration tests to see if the all this classes are working well together.

Dherik
  • 2,504
2

Answer to your question cannot be binary yes or no. It depends. It depends whether those 20 classes are result of class explosion due to bad design or is because of well thought of structured design. For example : While refactoring some of old code, I realized that by applying bridge pattern number of classes can be transformed from x*y => x+y. Same can happen if you think of decorator pattern.

So as I said, you need to understand if this 20 is because of x*y or x+y.

0

It happens that I need more than three classes for MVC - if the controller has to do something that is really complex, and it’s better to extract the complexity in a separate class, rather than making the controller bigger and bigger. Or if the view has a complex sub view, especially if that subview can be reused elsewhere.

That said, any extra class is extra complexity. So removing a small amount of complexity into a separate class is usually bad. If three classes have turned into 20, then unless what your controller was supposed to do was extraordinarily complex, this may have happened here.

gnasher729
  • 49,096