0

By these days I work in a legacy code that uses JAVA. The project has a code tightly coupled and low cohesion. All my teammates suffer to make changes in the software, one reason is that we haven't any behaviour test to secure that changes in software won't broken everything.

At the company that I work, the managers do NOT care about the software by itself, just about money and money. I mean, usually they don't create tasks to refactor or create tests, cause it will be a waste of money, they say: "the software is already working".

As a software engineer how can I prove to managers that it worth to refactor the code? Is there any metric to use? is there some methodology? I wanna know something like, how much money can I save if I refactor my software?

Everybody knows that the cost to add new features into the software become onerous, but how to measure it?

  • Borderline question (opinion based), but interesting. – πάντα ῥεῖ Mar 19 '18 at 19:12
  • 3
    You're never going to make this case. Instead of asking for time to do things that won't produce new dollars, just *build some time into your normal development process for refactoring.* – Robert Harvey Mar 19 '18 at 19:12
  • i'm not allowed to insert this time for refactoring into my normal development process. – Lucas Fantacucci Mar 19 '18 at 19:17
  • Agreed. Even if you could "prove" something, it wouldn't matter. Your managers only care about the money because that is what is in their best interest to care about and they don't care about the ever increasing costs of maintaining the code base because they do not expect to be in their current roles by the time that cost becomes onerous. – andy mango Mar 19 '18 at 19:18
  • @Lucas If managers don't listen to their engineers, and what's commonly considered state of the art, their business won't last long enough and fail to generate money in a long term view. They're just either overly dumb or too greedy. None of these ways is a good indication to stay for such jobs for a longer time. Run! – πάντα ῥεῖ Mar 19 '18 at 19:26
  • mango, you wrote the right sentence "the time that cost becomes onerous". Everybody knows that the cost to refactor a software become onerous, but how to measure it? – Lucas Fantacucci Mar 19 '18 at 19:30
  • 1
    @LucasFantacucci: Refactoring *is a part of your normal development process.* – Robert Harvey Mar 19 '18 at 20:59
  • @LucasFantacucci Nonsense. Refactoring falls into two categories: 1) Unblocking new development, and 2) Proving correctness. If you're expected to deliver X, and you can't deliver X because the existing codebase is too complicated to understand or un-extensible, part of delivering X ***is* refactoring** the existing code. And, as you deliver X, proving its correctness depends on others being able to actually *read* it -- which is often only achieved during refactoring. – svidgen Mar 19 '18 at 21:47
  • Tell your boss, "I'm not refactoring. I'm just cleaning it up a little so I can be sure it does what I think it does. ... If you can tell me how much uncertainty you're OK with, I'll know when I can stop refact--errr ... *validating*." – svidgen Mar 19 '18 at 21:51

4 Answers4

1

I mean, usually they don't create tasks to refactor or create tests, cause it will be a waste of money, they say: "the software is already working".

If it is already working, why do they employ you and your teammates to make changes? Clearly it might sort of "be working", but they want it to work better, to allow them to make more money. Otherwise they are just wasting money employing you.

So given they want to make changes, they should make those changes as efficient as possible. Quick, dirty changes are inefficient as they store up trouble for later. Every time you make a change, you all risk the entire application collapsing around you, or each change will just take longer and longer.

If they are in the business of making more money to sell the company in the short term, you are wasting your time and their money trying to write good code; that runs counter to the aims of the company. If they are in it for the long haul though, then investing time in refactoring will pay dividends in the long run as it won't get ever more expensive to make changes.

So your choices depend on their business plan. Ask them if their aim is to make lots of money in the short term only before selling. If so, go with it or change jobs. If not, then often the best thing to do is do the job properly without telling them directly: increase your estimates per task to include refactoring time. If you want to do it properly, quote a price to do it properly.

David Arno
  • 38,972
  • 9
  • 88
  • 121
1

Although I haven't had the chance myself to put this into practice, the Consortium for IT Software Quality recently released their Automated Technical Debt Measure standard as a mean to measure and calculate an issue tightly related to refactoring (or rather, the need for it).

That's the best chance to make the managers understand the need for periodical refactoring of legacy code. Of course, most developers will see the benefits in far less elaborated metrics.

1

I'm confused by the statement "cost to refactor a software become onerous" the cost of refactoring is a fairly linear thing. It's the cost of adding new features into a mess that grows exponentially. That's what you need to focus on. As a start, can you pull together stats on the development team performance over time? The management might be able to give you this information. Try asking for it.

Often management can see this happening but doesn't understand why. At the same time the development team starts talking about things like tests and refactoring. It's important to understand that from a business perspective, tests and refactoring provide no value added to the product. It's not a feature that adds or retains revenues. They can't advertise: "now with unit testing!" So from their perspective, productivity is lagging and your answer is to do more unproductive things. It's not going to be welcome, but it's necessary.

The point you need to be clear on this that these are things that are needed to keep costs under control. Try analogy: If you never change the oil in a truck, eventually it will fail and the costs to repair it will far outweigh the cost of proper maintenance. Railroad operators don't like paying for track maintenance (it's pure cost!) but if they don't they don't have a business. The Pony Express had a fresh horse every 16 kilometers for their riders. It wasn't because they like owning and caring for lots of horses and maintaining so many stations, it was so they could be really fast.

You need to make them understand that what they are doing is like trying to run a pony express but by flogging a single horse the whole way. It's going to get slower and slower and eventually stop moving entirely. Once you get them to understand the idea, you need to explain that the horse is almost dead. If they don't invest some time in rehabilitating it, they will never be able to keep up with their competition. You are not asking for time to tidy up. You are asking for an investment in time so you can make things move fast again.

If you need a historical example to provide them with, you need look no further than Microsoft. I recall reading an interview with one of the top development managers about how all that mattered was adding new features and cleaning up old code didn't matter. It was boastful, they were so much smarter than their competitors by ignoring about the pile of manure the were building upon (I tried to find this but it was a long time ago and I can't remember the name. I want to say it was Allchin but I'm not positive. Any help?) IIRC, this was right around the time of Longhorn which was to become Vista. It's not too hard to see how those choices lead to MS losing it's dominance to it's competitors.

JimmyJames
  • 24,682
  • 2
  • 50
  • 92
0

Refactoring is an integral part of software development... well... at least it has become as such for me.

I therefore always include the necessary time to refactor the parts that needs refactoring in order to implement the feature or solve the issue cleanly. By cleanly here I mean that I try to leave the code base in a better shape than it was before I started.

Now that does not mean that I will re-write the whole thing, I will refactor just the parts needed to get the job at hand done.

Sadly for some code base this is simply not possible. Their overall structure and architecture was neglected for so long that they are effectively "too far gone". Typically such systems are extremely expensive to maintain or to introduce new features in, a large part of this due to the technical debt that was incurred throughout it's lifetime.

Now I do sympathize with the bosses here. For them the bottom line is dollar and cents. You must therefore speak that same language if you wish to justify some major refactors. As you already know, the very definition of a refactor is a zero sum enterprise regarding the functionality of the software itself. Where you can mark some points however is if you can convince (yourself first, then them) with objective measurable arguments that the refactor will have an impact on other metrics such as deployment time, testability (therefore stability, though this can be harder to measure) and in the overall cost this software incurs in maintenance.

If your refactor would reduce intervention time by developer by (say) half while at the same time provide better guarantees that the overall stability will improve then you might have a point with them. Next is to assert how long this refactor work will take and measure it up against the gains ... get a positive balance... go for it... it's still negative, well, either dig further either until you find a positive balance or until you realize that the cost of making it good is so great that it's just not worth it.

Newtopian
  • 7,201
  • 3
  • 35
  • 52
  • I think a better measurement is maybe how long to break even. If it takes you 2 weeks to refactor something and it will take 2 years to break even in the time spent vs future time saved that is much harder to sell than 2 weeks of work where the break even point is 2 months. – Hangman4358 Mar 19 '18 at 20:39
  • That's the point of this exercise, it's a difficult one though. and it's not about breaking even really (though it is certainly a metric to consider) it's about showing that you can reduce the maintenance overhead and to be able to convert these savings in dollars and cents. Firstly this will speak their language and secondly this conversion will apply regardless if it's about shorter dev cycles or faster deployment or more efficient support structures. They are all good points but trying to explain them all will inevitably loose their attention as it (for them) devolves into mulble jumlbe – Newtopian Mar 19 '18 at 21:30