This Q&A is part of a weekly series of posts highlighting common questions encountered by technophiles and answered by users at Stack Exchange , a free, community-powered network of 100+ Q&A sites . is4 asks: I usually try to follow the advice of the book Working Effectively with Legacy Code . I break dependencies, move parts of the code to @VisibleForTesting public static methods and to new classes to make the code (or at least some part of it) testable. And I write tests to make sure that I don’t break anything when I’m modifying or adding new functions. A colleague says that I shouldn’t do this. His reasoning: The original code might not work properly in the first place. And writing tests for it makes future fixes and modifications harder since devs have to understand and modify the tests too. If it’s GUI code with some logic (~12 lines, 2-3 if/else blocks, for example), a test isn’t worth the trouble since the code is too trivial to begin with. Similar bad patterns could exist in other parts of the codebase, too (which I haven’t seen yet, I’m rather new); it will be easier to clean them all up in… Read full this story
- Could You Pass the U.S. Citizenship Test?
- Now here's the good news: Pioneering drugs that almost double bowel cancer survival time are among the medical breakthroughs overlooked in a year of Covid gloom
- Diego Maradona, one of the greatest footballers of all time, dies aged 60
- India vs Australia: BCCI formally writes to CA on relaxation of Brisbane hard quarantine
- I caught Covid from a hospital, we must give all NHS workers the jab – now, writes ex-Government adviser VIVIENNE PARRY
- My chest pains are terrifying – so why are tests all clear? DR ELLIE CANNON answers your questions
- Give adequate time for a probe
- Groundbreaking finger-prick cancer test is TEN TIMES more sensitive than current methods and could identify patients that are likely to relapse
- Britain breaches 1,000 daily Covid deaths for first time since APRIL and health chiefs post ANOTHER record-high 62,322 cases as Boris Johnson quietly extends draconian new COVID laws until the end of MARCH
- UK Test and Trace System Reportedly to be Outsourced to Logistics Giant Like Amazon to Meet Demand
Should I write tests for legacy code if there’s no time for refactoring? have 376 words, post on arstechnica.com at June 7, 2014. This is cached page on Vietnam Colors. If you want remove this page, please contact us.