12 ms·
Refactoring has a price, not refactoring has a cost
- jacquesm 3y agoRefactoring has a fixed cost, not refactoring has an ever increasing cost. Clearly either way you will pay but if you refactor you will end up paying much less in total. The bigger problem is not the cost per-se but the resource allocation issue associated with refactoring: you can go bankrupt with very clean refactored code that gives your competition time enough to bury you with a crappy codebase and the features that the customer needs. All of these are balancing acts. It's never 'refactor or not', it's how much to refactor and what to let go? These are strategic issues and they go hand-in-hand with business goals and knowledge about the longer term roadmap. For instance it would be pointless to refactor a codebase that will end up being supplanted by another product or for which a strategic acquisition is planned of a company with a technically superior product.
- lionkor 3y agoIt's also sometimes "when to refactor", because eventually you either have to refactor or rewrite (or retire).
- jacquesm 3y agoYes, correct, sometimes you will have to do it anyway but simply not now because there are more pressing needs. This more often than not leads to runaway technical debt though, and sooner or later the problem becomes insurmountable. I've found over the years that refactoring is best done as a continuous background task with a certain percentage of capacity allocated to dealing with it and addressing the parts that you most want to avoid first.
- sokoloff 3y ago> Refactoring has a fixed cost, not refactoring has an ever increasing cost. That means that refactoring has an increasing cost as well (with increased frequency, the total money spent on refactoring increases).
- jacquesm 3y agoNo it doesn't because you only write so much code.
- sokoloff 3y agoI think you’re then arguing that refactoring doesn’t have a fixed cost per occurrence, but rather that the more code you write between refactorings, the cost of the refactoring increases (which I agree with).
- seadan83 3y agoIf time is cost, then yes, everything has an increasing total cost. The question is more about complexity and interactions. Does a specific subsystem interact with N modules, or with 1. If N+1 module interacts with N, then the cost of maintaining that system will explode very quickly. OTOH, if the system is revisited after that test goes green to increase modularity, reduce dependencies, then complexity is now potentially growing sub-linearly to the number of modules rather than O(n!)
- candiddevmike 3y agoAny sort of refactor needs to have agreed upon goals/scope and folks need to stay within that scope. This is a really difficult skill IMO. Even when I start out with the best intentions of refactoring libraryA, suddenly I'm in a bad place refactoring libraryD because libraryA was refactored to use a new enum approach and damnit I want it to be consistent everywhere.
- lionkor 3y agoOne way I've seen this enforced is this: Have your "best" devs, the people who put out 2x the amount of solid, testable, well documented code as anyone else, you know those that carry the sprint, spend half their time reviewing. Your overall sprint velocity may go down a bit, but your code quality will go up. There's a magic to slowing things down, too - require reviews on every change, require tests to run and pass, run UI tests on each PR. Let people discuss good and bad code they see. Turn every little thing people mention, (like "man, this view is difficult to reason about", "the entire xyz class is a mess", "does anyone know why we do X here?") into a Refactor issue, discuss it, plan it, do it. You can do this during a big feature sprint, you dont need to wait until your product is done (then its too late). Refactor, let people say "yes this issue isnt high prio, but its important to me". Embrace when people want to make code better.
- mjr00 3y ago> One way I've seen this enforced is this: Have your "best" devs, the people who put out 2x the amount of solid, testable, well documented code as anyone else, you know those that carry the sprint, spend half their time reviewing. Your overall sprint velocity may go down a bit, but your code quality will go up. Problem with this is your best devs will soon become your best former devs. Becoming a "mandatory reviewer" sucks. Especially at scale. You're a bottleneck, you get pressured by other devs and occasionally management to let code that you don't like through, and if things go wrong you get assigned at least partial blame for not catching it during the review process. I'm speaking from a background of seeing this implemented at a major AWS service with designated "component owners", who were 1-3 developers with a final (and mandatory) review for all code merged into subcomponents. This was for a service with 400+ developers working on it. > There's a magic to slowing things down, too - require reviews on every change, require tests to run and pass, run UI tests on each PR. Let people discuss good and bad code they see. Yeah this is the way to do it. Automate everything. Unfortunately there's no real "good code" vs "bad code" easy metric, but you should at least have automated testing, linting, compiling, etc to ensure people aren't merging total garbage to shared branches.
- bluGill 3y ago
- jandrese 3y agoAttempting to future proof your code so you never have to refactor: the most expensive choice of them all.
- blowski 3y agoYes, for most business applications, in the long run it’s cheapest to optimise for refactoring than believing you can avoid it.
- ttoinou 3y agoThere isn't any long run for most businesses. Especially if your developers are that blinded by theoretical perfection as the author of this article
- bloopernova 3y agoWe're dealing with accumulated tech debt burying us right now. For years the team was told to deliver features, that the upgrades to node dependencies weren't of a high enough priority. Now some of the dependencies are so old they're complicating upgrading past node 12. Yet the cybersecurity people are demanding that vulnerabilities be fixed. Thankfully we have a stronger product owner now, and spent most of the last 6 months getting things updated. Yet there are still those in senior leadership who openly question why our team hasn't delivered the features they want. We're working on educating them. And something pithy and catchy is useful, so I'm definitely going to mention this in future: "fixing tech debt has a price, not fixing it has a cost." It's the kind of thing that if you can get a "cool" or influential senior leader to repeat, the rest will fall in line.
- preommr 3y ago> It's the kind of thing that if you can get a "cool" or influential senior leader to repeat, the rest will fall in line. sympathetic-lol at the desperate copium.
- bloopernova 3y agoIf I am honest with myself, it's about 40% copium and 60% experience with the directors in question. There's 2 "cool" directors who were tech people but are also influential in that peer group. You can't trust them to represent you fairly, but you can trust that they'll listen to your argument. The 40% copium stems from knowing that some of the "only features have business value" group are stubborn and think everyone should just work more.
- earnesti 3y agoI was working for a company, where the engineering team was doing this kind of refactoring, test development and what not mainteinance coding with large team for about 2 years. Meanwhile not many new business features were being developed and the competition took over, and eventually everyone got fired. I think the leadership was just too lazy to actually push the development of the product, but let the engineers do this pussy work of endless refactoring was big part of the problem. Not only one of course.
- awill88 3y agoAh yes, this short, click baiting article highlights the very predictable and widely known side effect of what we all know as the software development cycle.
- menotyou 3y agoFirst of all, how about using a programming approach which needs much less refactoring? Aka not using object orientation?
- porridgeraisin 3y agoYeah. Or any one paradigm basically. Libraries too, if they force you into a certain paradigm.
- menotyou 3y agoI don't program myself, but I do manage developers for 20yrs+. I normally don't care about what paradigm programmers use, but what I do empirically observe is that time spend on (automated) testing, refactoring and bug fixing is much higher in an object oriented environment. It seems from outside that the ability of producing reasonably bug free code is much lower when using OOP, hence the need of faster deployment cycles. Other industries went the way of producing good quality products whereas IT seems to use the approach to test the quality into the products and to fix, quite often when product is already at customer. This normally turns out be more expensive and have less quality in the products at the same time.
- TeMPOraL 3y ago> This normally turns out be more expensive and have less quality in the products at the same time. Hypothesis: software market has near zero barriers to entry, so while other industries are protected from would-be competitors by large up-front expenses, for most purely-software products anyone can rapidly build a half-assed clone of whatever you're doing and start eating into your customer base - making software companies obsess over velocity / feature delivery rate, and/or seeking all kinds of non-software barriers to entry (e.g. network effects, or content deals - like, it wouldn't be hard to make a better Spotify client, but good luck replicating the deals Spotify has with recording labels).
- porridgeraisin 3y ago
- somewhereoutth 3y agoThe most foolproof way to avoid regressions is to leave the code alone. The best testing is battle testing - if it is working well after plenty of contact with the customer then leave the code alone. Bitter experience has taught me this. --- I'm going to expand on my comment a bit - we need to be clearer on what (production) code actually is. We believe it is the definition of the runtime behavior of a given system (and of course it is exactly that). However, for any reasonably complex system, a complete understanding of the definition/behavior is beyond any single person. Thus code is in fact a recording of the social and technical process of producing the system, and as such embeds decisions and solutions that may not be evident to anyone just reading the code. When viewed in this light, it is easy to see how dangerous refactoring can be.
- gt565k 3y agoSure, but a lot of poorly written spaghetti code that works is sometimes impossible to extend or add new features to without a major refactor or complete rewrite. Currently dealing with some 13 year old objective C code for a mobile app that’s gonna require a major rewrite cause it looks like it was written by someone who should have never been writing code in the first place
- Gibbon1 3y agoThere is a mathematical technique called simulated annealing. https://en.wikipedia.org/wiki/Simulated_annealing https://en.wikipedia.org/wiki/Simulated_annealing The idea is code goes through development cycles. You have the most leeway to make changes in the first few development cycles. But less and less as time goes on. And the beginning of a development cycle you can make larger changes than at the end. Between cycles the code is frozen and you never touch it unless you can prove a change is needed. And development cycles are triggered by the need to for gross functional changes or interface changes.
- somewhereoutth 3y agoGood analogy. Where I am we try to follow this process for each release cycle - so big changes early, then becoming increasingly conservative as to what gets altered/added as the release date approaches.
- ttoinou 3y agoEither way you pay but the goal is to generate more revenue from your software than what you pay But one day all the cruft calcifies, and the numerous incompatible changes and features grind our progress to a halt. It is suddenly impossible to add new features without breaking something else That's also the case if you keep refactoring every day, there's no reason to believe the changes you're doing right now are that good. Refactoring and paying constant attention supposed code perfection has a huge unknown price that you have to pay very soon, whereas not refactoring has a future cost. You should use the money saved not refactoring right now to make something better later once the tech debt is too high but you know you have a good working software. In any case, this kind of article needs tangible examples to illustrate...
- blackoil 3y agoTech debt is like all other debts, it need to be serviced. You keep accumulating it and it becomes toxic. Never take any debt and you are leaving easy money on table and may loose to competition because you have slower delivery.
- reactordev 3y agoI agree with this. I’d go further and say it’s a visibility issue. Non-tech folks don’t know that the stuff is out of date, vulnerable, no longer supported. They don’t know how much debt they have borrowed. So having leadership know the costs, the cogs, the debts, and the projections is vital.
- myspeed 3y agoRefactoring is OCD, you can do it infinite times. Many times a working code is rearranged to match some one's preceptive of business logic.
- iopq 3y agoEventually you reach the limit of expression of the language you're working with. My fizzbuzz: https://bitbucket.org/iopq/fizzbuzz-in-rust/src/master/src/lib.rs https://bitbucket.org/iopq/fizzbuzz-in-rust/src/master/src/l... there's just no more refactors I can do because of the limitations of Rust
- TeMPOraL 3y agoYou eventually not only reach the limits of your language, but approach the limit of having plaintext code as your single source of truth and the thing you directly work on. At this point, it's like GP says - you can keep refactoring stuff infinitely. You won't be improving anything - you'll only be moving along the surface of limits of plaintext code, only ever making some aspects of code more readable at the expense of others.
- zeroonetwothree 3y agoOCD is a really difficult mental health condition that millions suffer from. It destroys lives and relationships. Please don’t minimise it by likening it to arguably fun parts of a job.
- corethree 3y agoI have ocd and he's right. Don't pretend you're a spokesperson for people who suffer from my condition. The condition in reality actually lives on a gradient and it very much influences everyone to varying degrees. It's only labeled ocd once it crosses a threshold. It no doubt exists in programming. Much of refactoring is done for the same mechanisms that cause ocd and zero practical reasoning. I have ocd but I'm able to differentiate my compulsions from rational reasoning. Thus I can see how irrational my actions are.
- majkinetor 3y agoEither way, somebody pays, not me necessarily. Clearly different thing then claimed. Current project owner pays for sure. But who will that be when collection happens, and what team will be directly involved, that's entirely another thing. My bad habits may cost me nothing, there is also probability of gain.
- AnimalMuppet 3y agoIf I"m the person who winds up inheriting the code you produce, I'm probably going to resent you. Do what you can, as if you were going to be the next person. For one reason, because anything else is irresponsible laziness. For another, you may in fact be the next person - you may not leave in time for someone else to inherit the mess. So do what you can now to minimize it.
- majkinetor 3y agoWho cares. - I don't even know you - 'Irresponsible laziness' could also be replaced with 'ducks in space' - I can leave any time. This is not slavery. So its a method of work - maximize the input, minimize the loss. You would be surprised. I actually know people like that, more then 1.
- SonicSoul 3y agooh wow.. refactoring is an art form. just because your code "works" doesn't mean you have to leave it alone. your working code will likely be copied into 5 other projects and will not scale well. ideally you're investing into creating shareable code libraries and into infrastructure that makes the process of maintaining/referencing shared components easy enough for engineers to want to dedicate their precious sprint time to it.
- nathan_compton 3y agoDoes this essay actually say anything non-obvious? Like everyone knows there are relative costs. That isn't the hard problem. The hard problem is evaluating those costs correctly.
- zeroonetwothree 3y agoPerhaps it’s useful for very junior folks?
- xyzzy4747 3y agoThere’s two kinds of people, those who like to build business value and those who are obsessed with refactoring and code perfectionism.
- swayvil 3y agoRefactoring has a price. Not refactoring has a cost. Either way, you pay PRICE. COST. PAY. 3 roughly synonymous terms used when one would do just fine. Why? For example : Refactoring has a price. Not refactoring has a price. Either way there's a price. This "clever writing" is a pet peeve of mine.
- zeroonetwothree 3y agoI would say it’s anticlever. Repetition is a far more effective device
- marcosdumay 3y agoPrice in what you pay to get it. Cost in what you keep paying to keep it. Price is pretty unambiguous, cost is very ambiguous. I've never seen anybody make this distinction, but IMO, it's clear enough.
- diatone 3y agoIt’s intentional, to distinguish between known unknowns and unknown unknowns.
- TeMPOraL 3y agoIDK, isn't this just "writing 101" you learn in primary school, that repeating the same regular word multiple times in close proximity (within couple sentences) is ugly and indicates bad writing?
- corethree 3y agoThere's no theory on good design. You organize your code one way versus another way nobody can really point to any mathematical proof or empirical evidence for anything. It's just one baseless arrangement vs. another. This is why, often, when you refactor code it doesn't make it better. You don't fully know if it's better. It's just another way. So even when you do this refactor stuff often you find yourself in the SAME situation even if you didn't touch it. Think about it. You follow best practices, you try to write code as beautifully as possible. That doesn't actually prevent a new feature from having you to gut a huge portion of your code to accommodate it. But developers don't realize this. They think the extra time spent refactoring puts them in a better place then before. But really they just can't see the counter factual. Did it really? I've been in places that emphasize on good code quality and put lots of good practices in place but they end up with "tech debt" anyway. Then when clean up day comes they blame it on bad practices and shortcuts but they're blind to the fact that the they were one of the most rigorous companies in terms of code quality.
- RangerScience 3y ago> There's no theory on good design. This is absolutely false. This talk: https://www.youtube.com/watch?v=3OgbQOsW61Y https://www.youtube.com/watch?v=3OgbQOsW61Y does an excellent job of introducing some basic theory on good design, with solid (heh) justification for each principle.
- corethree 3y agoThat's not theory. It's just a bunch of opinions. You can see plenty of companies that follow those principles and still end up in bad places. Theory is like number theory. You need axioms and theorems. Just because you assign acronyms and big words to things doesn't make it a "theory". You need proof or empirical justification. Solid is like scrum, someone made it up. It was pulled out of someone's ass. Doesn't mean it's bad, but it's not categorically correct, it's more of someone's opinion. Something that is categorically correct is complexity theory for algorithms. You can definitively say Algorithm A is better than algorithm B from a performance perspective. But for program design and organization? Is one design better than another? How Solid is one design vs. another design? Can you concretely even define Solid in formal terms? No. I say again there is no theory on software code organization. None.
- RangerScience 3y agoBeen having this fight a lot lately. The phrase that seems to have struck a chord is ye olde "first you make the change the easy, then you make the change". As a further elaboration, I'm trying out that this gets you: - Better position. Code's better, so product is better (more stable, with better features, etc) - Higher velocity. Each time you do this, the overall codebase gets easier to change, because you're continually making it easier to change - High acceleration, because you're giving your devs a way to stretch their capabilities and grow their skills. Definitely gonna see how "Refactoring has a price. Not refactoring has a cost. Either way, you pay" plays with folks! PS - AFAICT, future proofing is bad when you build stuff to aim it, mostly because you probably won't end up with the problem you think you will, so you're not actually able to build it correctly now. But! You can build in gaps, for where that new stuff can go. You can future proof pretty much only by writing your code today with eye towards making unknown changes later - ye olde "the only architecture that matters is the one that lets you change".
- karmakaze 3y agoYes! this quote captures my reasoning of factoring before rather than after. The other problem with factoring after is that it's doing so without knowing the future new motivations. I would say that the factoring after is to suit making a working prototype first, then when a factor is identified aligning the design/source along those lines. Note I say factor rather than refactor since in most cases the existing code wasn't factored in the first place. It's also a reminder that we should know what that factor is before making changes. In some cases there is a new reason that changes which to factor but is less common IMO.
- pacificmaelstrm 3y agoI've been at a company where we had two leading developers. One refactored everything endlessly to a fault, wrote tests for everything and emulators for every external piece of hardware. The other rarely/never refactored and was focused on ends-justify-means functionality. They hated each other and progress was very slow because they could not work together at all. My two cents is that all products of engineering are temporary. Software (and hardware) are not eternal. What you write today you will eventually become obsolete. Your entire app will eventually be re-written. If not by you then by your competitor who takes you out. There is no such thing as perfect or optimal code because what is great for now won't be great for tomorrow. With that in mind, good refactoring is like good math. Taking a long and complex system of code and replacing it with something functionally better and far simpler and easy to understand. Bad refactoring is just moving things around for "understandability" or in a lot of cases one developer rewriting something in their own idiosyncratic style because they don't understand the style of the programmer before them. And the final point is don't be afraid to rewrite the entire system if you have that ability. Since the development process is about defining functionality as much as enacting it, once you have a finished application, you can re-create it much faster and simpler than it was originally written. The Apollo missions got to the moon and back with 145000 lines of code you don't need 20 million + for your web app.
- SoftTalker 3y ago> What you write today you will eventually become obsolete. True, but "eventually" can vary wildly. Web app front-end written in framework-du-jour? Yeah it will probably be gone in a few years. OS kernel functions? May still be running unchanged 30 years later.
- goalieca 3y agoThere two kinds of phases a product lives under: growing and maintenance. Maintenance mode products aren’t growing revenue. They might get a few new features but the main goal is to not mess with the cash cow unless you need to patch or make a special customer a new feature. It will fade into irrelevance with time as something new replaces it. Projects that are growing need to scale and adapt to new environments and use cases. If you treat these with disrespect then your business will suffer and you’re less likely to make that new feature or big pivot needed to become a cash cow.
- readthenotes1 3y agoPrice: what consumers pay to acquire Cost: what producers pay to supply Refactoring has both
- karmakaze 3y agoI often find myself (re)factoring when beginning work if the codebase is not in the shape (design rather than quality) that it needs to be in for the particular new features to fit well within it. The reason I wouldn't factor after implementation is that it should have followed a design that already identified the factors that are being separated. Whenever there's continuous refactoring, the factors aren't so much known and decided at a high level, it's typically more an exercise of deduplication. If you can't name the thing (or why) you're factoring it's blind deduplication, which still has some value but is much lower. If someone says they want to refactor, I'll ask what's the factor and why. A system separated along well chosen seams allows things to naturally and easily fit in its design.
- nuancebydefault 3y agoI often see that code is being refactored and there you have it, refactored code. But usually the problem is not in the code but rather in the design / architecture that has driven the code. The design was made without a diligent machine like a computer with compiler checking it. Design reviews (by people) are boring and it hurts when someone pokes holes in one's design that has come to them after a few days and or nights of thinking. Also it is often based on unclear requirements. So that's how code is born, which is based on suboptimal or even backward designs. As soon as there is need for refactoring, usually only the code itself (a whole of tiny design decisions) is revamped, keeping the initial design alive.
- godelski 3y agoI definitely think you're right about that we can't write perfect code upfront. Not to mention that the environment is changing, so left still software will rot. BUT I do think at times we need to slow down. Too much "move fast and break things" and sprints have many opportunity costs. Long term optimization is a hard task, so people typically focus on short term gains, which we should be aware can leave a lot of money on the table. So don't confuse moving fast with maximizing profits (e.g. we invest in ourselves by going to school turning away immediate profits for higher future profits. But this is harder for businesses to do). A good manager/CEO should be one that is learning and focusing on this optimization problem, not the next quarter or ill defined metric. > Design reviews (by people) are boring and it hurts when someone pokes holes in one's design I think there's a lot to be said here too. A not uncommon gauntlet many scientists have to go through is getting their work trashed on. With many lab groups purposefully holding mock presentations and being overly critical to help train the junior scientist's confidence. We should do this in review too, making sure to do it with juniors. It's slower, but pays high dividends. But review, in any form, has another problem. The reviewers themselves. Paid or unpaid, they often frame their job as being to find flaws in a work. Instead, their actual job is to make the work the highest quality it can be. If you frame the reviewer reviewee relationship as adversarial then you're (in general) degrading the system. Rather this always needs to be framed as cooperative, where you're working together to make the work better. This means that it is perfectly okay for a work to be accepted with no comments, and in fact that should be the goal of any QA system. That your job often is closer to a teacher and your success is reducing your work. But if we frame adversarially you're going to use metrics like the number of QA comments and rejects to determine how good your reviewers are. In turn, this will be a cobra effect and people will purposefully create low hanging but easy to fix mistakes so that reviewers can point to something (demonstrating they did their job and their need) but reviewees can fix the problems and everyone is happy. But that's just Goodhart's law in action and isn't optimizing the product/profit/work/whatever. This does need to be kept in mind since many metrics are nowhere near aligned with the actual thing being desired to be optimized (and there's environmental drifts too).
- jillesvangurp 3y agoThe cost and price scale non linearly to the amount of change. So, waiting to refactor has an exponentially higher cost the longer you wait whereas doing lots of small refactoring as you go has a relatively low cost. To the point where it's just negligent not to do it. You can spend five or ten minutes cleaning up a little or you skip it. Not doing it is sloppy. Just apply the boy scout rule. People have the wrong reflexes where being overly conservative and fearful to change a working system eventually leads to a system that becomes so hard to fix that people stop bothering to even try and just replace or retire it in the end. Which is very expensive and destructive of course. Usually such decisions become a reality when people leave or change teams and it turns out there's nobody around that even has a clue where to begin fixing the old thing. Getting rid of the thing then becomes the logical choice. Calling it technical debt is a way of talking yourself into believing you can deal with it later. Quite often that doesn't work out that way. Another fallacy is believing the debt is something with a fixed/known price that you can pay off at the time of your choosing. You can't; it's literally risk that accumulates that you haven't properly analyzed and estimated yet. Some of it might be fixable, some of it might not be. You won't know for sure until you sit down and do the work. Deferring the process of finding out is what gets teams into trouble. The less you know what you can still fix the more likely it is that the cost has become stupendously high. Half the work is just knowing what needs doing and how it needs to be done. That doesn't mean you do the work right away. But spending a lot of time chin stroking over stuff you could do without actually doing stuff (aka. analysis paralysis) is also not productive. Finding a balance between knowing what needs doing and then just balancing new stuff vs. making sure that the cost of that new stuff isn't overly burdened by broken old stuff is the name of the game. Having a lot of technical debt usually translates into work that ought to be quick, simple, and easy being anything but those things. So, the technical debt metaphor means that you burden the cost of future essential work with that extra burden. Until you fix it, it only gets worse and worse. You pay the interest on every change until you fix the problem. And you won't know how expensive that is until you do it. That's why you should refactor a little bit all the time. Low cost, it lowers your risk, and it keeps you aware of all the pain points and weak points in your system.
- nunez 3y agoAgreed. Refactoring is like cleaning your house. Spending ten minutes cleaning/organizing your place daily is much less painful than waiting until that one day a month and spending 3-4 hours doing it. At least for me, anyway.
- j45 3y agoOne aspect of technical debt is simply accumulating less until the lightbulb moment arrives to include mandatory refactoring. Build the least number of features you need to.
- hansvm 3y agoExpanding slightly on the article, there are at least a few places where incremental refactoring is (often) beneficial: (1) Before you work on a feature, if the existing code has some tradeoffs or outright deficiencies which make the new feature hard to add, start by fixing the work site, and then add the feature. The benefits from this snowball quickly on code of any age or complexity, and since the assumption is that we're only doing "extra" work when a feature was going to be complicated and that the "extra" work makes the feature simple, it doesn't actually add a meaningful amount of time to your tickets (i.e., throughput slows down a bit at the beginning but not enough for management to notice or care, and it ramps up over time). (2) A fair number of developers seem to "think" in code -- incrementally building out the solution in code to learn how to solve it and build appropriate mental models. If this describes you, throw away the first draft and start over. V2 takes a fraction of the time to write as V1 since you now know what you're doing, and the second draft will be substantially better. If this gets pushback, never describe V1 as "working" or a "prototype" or anything vaguely implying that enough duct tape and unpaid overtime would allow it to hobble along in production. I find that "brainstorming" often elicits the correct response. (3) The article calls out that after building a feature "correctly" it might not fit perfectly into the existing code. I'm not necessarily convinced that the right time to refactor this is immediately (since it's so hard to predict which abstractions you might need (ignoring rules of thumb like "separating payments and entitlements", which represent hard-won tribal knowledge)), but if you're able to come up with a measurably better solution then the best time to implement it is definitely while everything is fresh in your mind and before you bug your coworkers for a review. (4) The article _also_ calls out that cruft has probably accumulated over time, which might need to be handled incrementally or with a rewrite. A lot of that is often addressable via (1), but partial rewrites _can_ be cheaper than you think. If you happen to notice a particularly thorny problem afflicting an organization, can confine it to under a few thousand lines of code, and have a decent idea for how you will make it better, spending a couple days to rip it out is time well spent. I've worked on a lot bigger projects before than those sorts of quick rewrites, but those small changes have had a comparatively outsized ROI. They're fast projects that nobody else had any good ideas for fixing (or they would have done so rather than bitch about how much of a hassle the thing is) that can immediately save 1+ developer days per calendar day or 10 GPU years per calendar day or whatever. Your work pays for itself quickly, and since it only took a small fraction of your time you still have nearly identical throughput on whatever your main job is. (4a) No longer job-related, but a similar idea manifests itself in ordinary household functions as well. If you have a low-risk, low-cost method for achieving 10%+ annual returns, that's often worth considering. Consider buying flour or soap or something in greater quantities than normal. It's not uncommon to pay 2x the price for 5x the quantity. If you go through the item every 2.4 months (illustrative, to make the rest of the math easy), consider the relative effects on your wallet from buying in bulk. You spent 2p (for some unit price p) immediately (and couldn't invest it or do anything else; it's gone), but at the end of the year you have 3p more cash than you would have had you bought smaller units. I.e., your 2p investment grew 50% to 3p. That's an amazing annual return that you couldn't easily replicate elsewhere, even after accounting for tax-deferred benefits or other such effects. Similarly, paying some portion off a 20% interest loan (try to never get those...) has, ignoring taxes and bankruptcy and other such details, exactly the same effect on your net worth as getting 20% returns in some investment account. Moreover, it's nearly "risk-free", whereas such a high yield investment account would not be. (4b) Individual circumstances vary. Try to interpret (4a) in a charitable light; if you don't bake much, don't buy 10yrs worth of flour. If you have to buy extra square footage to plan to buy in bulk that's maybe a problem. If you require a ton of time to avoid scams or quasi-scams (like stores pricing bulk items with a higher per-unit cost than non-bulk items) then that's potentially a cost that keeps it from being worth it. The point though is that on the scale of a single person going through a single life, there are lots of small things you can do which have outsized returns (education and learning fall into that as well IMO, but this comment is long enough), far beyond the strategies which work at the scale of a retirement fund.
- guillemsola 3y agoI like this sentence as it's something business stakeholders can unddo. And even the article focuses mostly in refactoring it can be used with many other good habits. For instance monitoring has a price to set it, configure it... You can avoid part of the price by setting up a simple monitoring It has a cost as you're not going to catch early on issues in prod. And the latter you realize something is no going well, the higher the cost will be to fix it, loss clients... And we can go on with many things as well, UX has a price, testing has a price, backups have a price... Hopefully the writer don't think he has found the final reason to justify why refactoring is a must as there are many other best practices were low price will imply higher cost at the end. Wasn't that what we used to call tech debt? XD