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
  • 2
    sounds like good practice to me. how can we judge which of you is right? add some source code – Ewan Mar 10 '18 at 20:16
  • 1
    @Ewan “*e.g. base class and multiple derived classes*”. Don’t see much good practice going on there as inheritance is inherently (pun intended) bad practice;) – David Arno Mar 10 '18 at 20:24
  • You get what you pay for. If you don't like the code you get, you better don't outsource. – Doc Brown Mar 10 '18 at 20:29
  • 1
    maybe a little out of fashion, but jot bad practice – Ewan Mar 10 '18 at 20:32
  • @DocBrown Not my choice. It's the higher ups' fault. – Questio Mar 10 '18 at 20:32
  • SOLID code by definition has a higher number of smaller classes. Knowing nothing other than what you said, it sounds like you found a really good team. As for your question `what is a good strategy`?, I'd recommend asking them for some material about their philosophy and learning why they do that. At worst, you'll have a stronger case to argue against it. – John MacIntyre Mar 10 '18 at 20:35
  • I am voting to close because this is all opinion. The way it's written there isn't a way to answer other then choosing a side. Might as well ask vi or nano. – coteyr Mar 11 '18 at 03:42
  • @coteyr definitely nano. :) – David Arno Mar 11 '18 at 07:55
  • @Questio: What is your role in relation to this outsourcing company. Why were you asked to evaluate their work? – Bart van Ingen Schenau Mar 11 '18 at 07:58
  • @David Arno Hold tool at wrong end -> result disappoints -> tool sucks – Martin Maat Mar 11 '18 at 08:37
  • @MartinMaat, that depends on the tool of course. Hold many at the wrong end and there'll be blood everywhere and a visit to A&E required. – David Arno Mar 11 '18 at 08:58
  • 2
    Voting to close for lack of clarity. The question title implies you want to know how to find the "right" breakdown of classes (in terms of quantity and size). But, you ultimately ask about *how to deal with consultants giving you crappy code.* ... If that's really what your asking, careful what your angle is -- "how to make friends and influence people" is not exactly on topic here. – svidgen Mar 11 '18 at 16:47
  • If the code looked good I doubt there would be a posting here. Many would call this "ravioli" and complain about the difficulty trying to follow it, while the original authors will tell you it makes it more "readable". SOLID is pure cargo cult design. – Frank Hileman Mar 12 '18 at 04:16
  • This is a real problem. It mostly emerges from following an architecture pattern blindly. Every slightest feature change results in many many "manager/controller/presenter/view/model" classes in developers favorite architecture pattern. – S.D. Mar 12 '18 at 08:47
  • Put on hold probably because it is a social problem (cult-like programming) and not an engineering problem. If you can't get rid of the outsourcing company, and throw away the code, you probably don't have many options. With an employee, deprogramming the individual can be possible, depending on the strength of their original critical thinking skills, and the depth of the cult-like hold of ideas. – Frank Hileman Mar 12 '18 at 20:55

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
  • 102,279
  • 24
  • 197
  • 315
  • Personally, I'm pretty dubious about SOLID, as it often is misunderstood and misapplied. However, this answer brings a more objective and nuanced look at the problem than what I would have written. :-) As for OP, I think the following is most important: **"Their code, ... barely works and is constantly breaking."** – user949300 Mar 10 '18 at 22:44
  • @user949300 that certainly is a problem. But one that can only be fixed once we understand why. The op doesn't seem to be able to read the code base. As far as I'm concerned all other problems can wait until it's readable. – candied_orange Mar 10 '18 at 23:01
  • What the OP describes is not what "programming in the small" means. In fact, what's described sounds more like "programming in the large" techniques being applied even where they are unnecessary/overkill. – Derek Elkins left SE Mar 11 '18 at 01:07
  • Wow! Great answer and nice application of Herbert's Simon work on short term memory and chess player – Christophe Mar 11 '18 at 10:51
  • @DerekElkins I can't be sure it's what they were doing but when I said programming in the small I was thinking of [this](https://youtu.be/WpkDN78P884?t=29m20s). – candied_orange Mar 11 '18 at 14:37
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,406
  • 20
  • 33
  • Of course their code constantly breaking is necessarily a problem! No sane strategy considers that acceptable. – JounceCracklePop Mar 13 '18 at 08:28
  • Hi Carl. Maybe my english was not clear, but I'm trying to say that the tiny classes is not necessarily the cause of the code breaking. – Dherik Mar 13 '18 at 10:06
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.

rahulaga-msft
  • 1,402
  • 1
  • 11
  • 24
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
  • 42,090
  • 4
  • 59
  • 119