91

Preface, TL;DR

This question is about the implied tradeoff between the speed of development and the quality of code.

I am looking for methodologies which can be followed in order to optimize development speed, even at the expense of code-quality and the accumulation of technical debt.

I am not looking for ways of communicating the importance of code quality to those in charge. Please assume everyone understands the importance, but have chosen to optimize for speed of development and that they are correct in that decision.

I have learned a lot about how to optimize for quality, but nothing about optimizing for speed of development, and am looking for references.

My personal experience taught me quick and clean go together, which is not what I see around me, making me believe I am missing something very fundamental.


Code in real life isn't good

I keep encountering code during my work that is less than optimal. By that I don't mean simple improvements could be made, I mean:

  • Lack of encapsulation ("what" mixed with "how" on several levels)
  • Multitude of duplicated conditionals over different modules
  • Under-abstraction
  • Wrong naming
  • Lack of tests
  • Any other poison you can come up with

This is way beyond things that a short refactoring session can remedy.

I see this over and over across many software engineers, across several seniority levels, and across several (startup) companies.

When talking to colleagues outside the office about it, the vibe is "The code is always bad. You have to learn to deal with it" (which I am trying to do now). When talking gently with colleagues from the office, they are either not aware of the problems (mostly juniors or non software majors), or they excuse it by "we had to get it done fast".

I am beginning to believe that if so many seniors claim they optimized development speed at the expense of code quality, they have some secret method of getting it done, repeatedly, which I somehow miss. Otherwise, how did it get to be like this? I mean, this has to be done deliberately, right? No one wants tie both their shoes together, though sometimes they have to. Even then, there has to be a correct and a wrong way to do it.

I believe this is code in real life. I read a lot about good code. For example, The Gang of Four, Clean Code[non affiliate link], lectures, and SOLID.

I observe that these practices are considered by many as nice to have, but are not followed in practice, especially when under the pressure of business, or if people don't code as a passion, and don't extend their knowledge or notice patterns by other skilled programmers.

This tendency of code not being perfect will probably be amplified on my own career path, which is leaning toward algorithm development, and away from pure software engineering.


What do I do today?

When I write code "from zero", it is very easy for me to implement the good-code principles, and I tend to be faster as I write good code.

I tend to follow my own code much better, thinking less and typing more, having fewer bugs, and able to then being able to explain to myself and others what's going on, when it is organized. I feel this makes me faster, as most of the time coding goes for thinking, and writing tests, which good code minimizes, and encapsulates.

When handling existing, good code, there is a slight learning curve, but then I can treat it quite easily, and not worry that I might break things. I can be quite sure I am on the road to being done and explain what's going on and estimate how long it will take.

When handling existing bad code, I tend to:

  • Not know what I am going to break with my changes.
  • Not know how code is structured and have to read the whole thing prior to writing, which is virtually impossible due to wrong naming and no encapsulation, no external documentation, and generally asking people results in "oh, yeah, there's also that case" if they are still even around.
  • Start to build encapsulations myself, just to know that when I'm done, I am really done, and that I didn't break anything. Also this allows me to not break my own changes elsewhere.
  • This is a really slow process, relative to the person who wrote the code, who knows by heart all the pitfalls in the code.
  • This is much slower than the boss expects.
  • I usually can't give a time estimate for my work prior to going into such code. Many times, I only find out about the code quality after having spent some time in it.

When being asked to code "quick and dirty", I have no idea what to do in practice. I can code quick and clean from zero or slow and clean.

I want a tool in my arsenal, to be able to code quick at the expense of dirty, to be able to choose when to use it.


This topic seems clear to everyone, but no one actually talks about it.

Bosses and colleagues, mostly at startups, all say once in a while "quick and dirty" or "do it faster; we will repay the technical debt later", or "just get it done; deal with it later".

I never hear people talk technically or methodically about how, in practice, to favor quick and dirty over clean and slow. As I view it, quick and clean go together when "actually working code" is implied.

How can I get all three done together, in new code, and in existing code?

  1. Deliver faster than when writing clean code (implied doing something dirty)
  2. Writing working, tested, explainable code (sleeping well, not worrying production servers just broke because of me)
  3. Working regular hours

I understand how to write good code. I want to find out about methodologies of being faster at the expense of quality.

I am looking for methodology, rules of thumb, and book or lecture references.

Gulzar
  • 1,240
  • 5
    You speak of "existing bad code", but bad code comes in different flavours, which seems to be the source of your confusion. There's a world of differences, for instance, between code that is not tested automatically, and well-tested code that would be refactored to an architecture that better fits the current needs given the team had time to do so. – Vincent Savard Apr 08 '22 at 14:15
  • "Writing working, tested, explainable code" - quick'n'dirty code is neither of these. It's dirty. – Bergi Apr 09 '22 at 04:28
  • @Kevin can you explain please? – Gulzar Apr 09 '22 at 11:06
  • @Gulzar "working": it doesn't (properly) work. "tested": it isn't tested enough, if not tested at all. "explainable": no one is able to understand what it does without the presence of its writer. Even the writer himself may not understand his own code after a while. – Zakk Apr 09 '22 at 22:00
  • Re "optimize for speed of development". Only in the short term, presumably? Like in to the next deadline. – Peter Mortensen Apr 09 '22 at 23:01
  • 14
    In the headline you are asking how to write quick and dirty code, but later you ask how to be "Writing working, tested, explainable code [Sleeping well not worrying production servers just broke because of me]"?
    So which one is it? Maybe the issue of your sleep needs to be addressed before everything else
    – Helena Apr 10 '22 at 09:19
  • Your assumption that code not conforming to the latest commandments coming from the ivory towers is invariably bad, does simply not hold. – Thorbjørn Ravn Andersen Apr 10 '22 at 10:28
  • @ThorbjørnRavnAndersen "bad" is a convenience word for getting on with this wall of text. I am looking for how to deal with such code. Judging it is irrelevant. – Gulzar Apr 10 '22 at 14:27
  • It just means coding without thinking about design -- consider each of the things your code has to do, and make each of those happen in the quickest way you can. How well that works out depends on your familiarity with the problem space and how you've developed your instincts. You never get anything really nice, though. – Matt Timmermans Apr 10 '22 at 14:31
  • 7
    The code in the Gang of Fours design patterns book is not “good code”, never claimed to be good code, and it’s authors have spent a good deal of time explaining that. It’s simply code that works. That’s only needed in languages that don’t provide simpler ways of doing the same thing. Mindlessly following patterns does not create good code. It only creates recognizable code. Having a name for it doesn’t make it good. – candied_orange Apr 10 '22 at 19:35
  • 3
    @gulzar in that case, the best way to write code quickly is to practice. Having written lots of code allows you to recognize what is needed for being able to test, abstract etc, and what is the actual meat of the code which you by then also know where to put to avoid having to put all the scaffolding in place. So, this comes with experience. – Thorbjørn Ravn Andersen Apr 10 '22 at 22:04
  • @thorbjørn practicing blindly is useless. I want direction in practicing – Gulzar Apr 10 '22 at 22:11
  • @Gulzar It’s like The Game. If you’re thinking about it, you’re not doing it. – user3840170 Apr 11 '22 at 06:13
  • There is an article from Martin Fowler that discusses this Quality vs Speed tradeoff: Is High Quality Software Worth the Cost? – Martin Apr 11 '22 at 07:47
  • 1
    I am wondering how nobody wrote this "quality, speed, costs - you can pick only 2". – BЈовић Apr 11 '22 at 10:33
  • One good way to write good code quickly is to not have to write new code -- i.e. to have good-quality pre-existing code available that you can impress into service to handle the new requirements, with little or no modification. This is fast because the existing code has (hopefully) already been largely tested and debugged, so you don't have to go through those steps with it. Whenever I write new code I try to keep half an eye on making it re-usable, so that over time I build up a library of ready-to-go drop-in components for future re-use. – Jeremy Friesner Apr 11 '22 at 15:19
  • 2
    @candied_orange : What makes "good code", then? How do you know if you code is at the quality level the OP seems to be able to achieve near-effortlessly, instead of racking yourself for hours, weeks, or months into analysis-paralysis quibbling about rules and theories on how to make it, continually re-kneading the code because you always can seem to come up with contradictions in the rules in seemingly basic scenarios? How do you get a solid, trustworthy answer on what "good code" is so you can know if you're making it? How did OP manage to learn this instead of being years in rethink hell? – The_Sympathizer Apr 11 '22 at 20:09
  • with projects almost always never being completed because of the obsessiveness and trying to get how the rules can fit when they are presented in such an absolutist manner? – The_Sympathizer Apr 11 '22 at 20:10
  • There are currently two close votes on this question, but I feel it should remain open. It's a reasonable question, it pertains to something that is not discussed or explained as much as it probably could/should be, and on-topic questions for this site warrant at least slightly more open, subjective answers than ones on Stack Overflow. – Panzercrisis Apr 11 '22 at 20:49
  • 1
    I reject the premise of your question. It implies that only two options exist; quick and dirty or clean and slow. I see no reason why you can't write code quickly and cleanly or slow and dirty. – Justin Ohms Apr 11 '22 at 21:44
  • 1
    @The_Sympathizer You learn if code is good code in a code review. You learn if features are good features in a demo. Your concerns are not new. They have names. Gold plating. Gold fishing. The cure? Minimize time spent without feedback. Otherwise it’s all to easy to disappear into a problem, solve it, and find that no one cares about it anymore. – candied_orange Apr 11 '22 at 22:02
  • 2
    @candied_orange : so basically the real problem is when you don't have access to people who can give you feedback. How was OP then able to avoid these problems and not get stuck on "gold plating"? How do you get continuous access to those who can give feedback, when you aren't doing coding as a job? – The_Sympathizer Apr 11 '22 at 22:09
  • 1
    @candied_orange Or to extend The_Sympathizer's comment, even once you are doing coding as a job, how can you get continuous access to those who can give good feedback, if your colleagues don't happen to live up to the ideal? Bad feedback is useless at best and harmful at worst. If the majority either don't have enough experience, are too junior, or haven't kept up with how technological changes have changed design tradeoffs. – user1937198 Apr 11 '22 at 22:37
  • If we're talking about pressure for quick and dirty with colleagues accepting it, then is it not possible your in an environment where your colleagues are writing quick and bad code. Are they going to give good reviews? – user1937198 Apr 11 '22 at 22:37
  • Stop asking for perfect feedback. Just get feedback. If you can get your mom to look at your code and explain what she thinks you were trying to do you’re better off then you were spinning out on this alone. Good code can be understood by the cpu and someone other than the one who wrote it. – candied_orange Apr 11 '22 at 23:17
  • This question started to get sudden traction, please comment if you are coming here from a reference – Gulzar Jun 23 '22 at 09:14
  • If you want to optimize for development speed try optimizing for getting feedback from and about your code. This applies to both clean and dirty code. Then for "quick and dirty" consider for the given situation what things that you would normally do in clean code that you can leave out. I.e. in some situations you really only need the golden path to function correctly and you can omit a lot of the error handling. – Bjornicus Jun 23 '22 at 20:27
  • Usually, if you favor quick and dirty code initially, it will slow you down later. For example, copy and paste is fast but at some point, you would need to update all copies when a bug is found. Same thing by using hard-coded constants. It is fast to write initial code but hard to update it later. Same thing by writting somewhat long functions (might be faster until it is hard to reuse because it does too much)... Thus quick and dirty should only be used for very small project (a few days) for example to do a one time operation... – Phil1970 Jun 23 '22 at 22:17
  • @Phil1970 That only applies when the team culture can avoid quick and dirty. If the team culture prefers quick and dirty, the long term is going to be slow. As an individual you have a choice of clean code (up front slow, and long term slow once the culture gets its hands on it), or quick and dirty (up front fast, but long term slow). So not going for quick and dirty just singles you out as the one who is slow and troublesome upfront, without any longterm payoff. – user1937198 Jun 24 '22 at 00:40
  • 1
    There are things that you just can't do quickly with old bad code. Some functionality in the code may just be too hard to understand in a reasonable amount of time. So what I do in that case is to identify what functionality can be added/changed relatively easily and tell the stakeholders that this is what you can get quickly. This other thing will take a lot more time as there is already existing technical debt that needs to be paid back. – Simon Byholm Jun 24 '22 at 19:44
  • 1
    @Gulzar re your update: There aren't going to be any books or formal guides to doing things quick and dirty. It's not a paradigm that anyone REALLY wants to formalize. It's pragmatism. It's recognizing that if you write a function to merge two lists that you will use to merge 10 element lists, then no one cares that it is horribly inefficient for merging 1000 element lists. Stop fussing. It doesn't matter. It's about NOT encapsulating what others didn't encapsulate. If they got by without that then you can too. Don't understand the whole module, just grasp the function that you need to fix. – Sinc Nov 21 '22 at 15:05
  • 2
    @Sinc Everyone keeps saying these "just" sentences. I fail to do that, because you actually didn't say anything. There is a lot of benefit in formalizing this, as this is actually how things work, and understanding life as it is is more useful than understanding ideals in many occasions. Answers with "don't worry about it" or "just succeed" are useless. Not understanding how what you are doing breaks other places (that did not protect themselves) is just doing bad work. – Gulzar Nov 21 '22 at 16:19
  • @Gulzar you're trying to formalize informality. It can't be done. Doing things quickly but somewhat dirty is about knowing when to quit, when enough is enough. That is bound to be empirical, and will change from situation to situation. Suggestion: Try https://adventofcode.com/ as a practical means of trying to code quick and dirty. It's a programming challenge site, and the goal of each exercise is simply to find the correct answer. The code is not inspected or shared unless you want to. Try some of the challenges, as quickly as possible. JUST get to the answer, without caring about anything. – Sinc Dec 13 '22 at 14:27
  • @Sinc Advent of code is not nessicarily helpful here as it that is greenfield project. A big part of the problem here is how to deal with brownfield code, and small coding challenges don't give you that. – user1937198 Dec 13 '22 at 14:39
  • @user1937198 That's true, but Gulzar is having a problem in any case with the concept of quick and dirty. A programming challenge would be a good way to practice "enough is enough". My coding solutions for it never have error checking beyond what is critical, don't handle edge cases until I run into them, aren't coded beautifully, and have no unit tests unless I run into something that a unit test might help me find. He needs to find the mentality to quit when things are done, so a challenge might be just the thing. – Sinc Dec 13 '22 at 15:01
  • @Sinc I think this will not be helpful, as this doesn't tackle the bigger issue of dealing with open-ended, existing code, which my changes may break. But I see the mentality you propose, which is helpful. Thanks – Gulzar Dec 14 '22 at 09:32
  • @Sinc and the fact that things "change from situation to situation" as you put it, does not mean they can't be formalized. All of software development "changes", though patterns can be found to make it more technical and repeatable. – Gulzar Dec 14 '22 at 09:35

15 Answers15

81

Use the 80:20 rule (Pareto Principle) And a "TODO" notation.

Or, as given here, "80% of the task is completed by 20% coding".

A large amount, ~80% of your code, can probably be written cleanly, and quickly. Do that. Say you need to add functionality, and a class or module already exists for it. Just add it to the obvious place. Follow the existing naming conventions. Add basic unit tests. Build on what's already there.

~20% of your code requires more thought. You aren't sure how to test some obscure edge case. You can't decide about the added functionality - should it be in a subclass, or use D.I., or some fancy Gang of Four pattern. (etc...) As your mind wanders you start to research a new tech buzzword and spend hours on Stack Overflow.

STOP.

  1. Just do something quick and dirty.
  2. And a TODO comment.
  3. Come back to it in a couple of days.

It's amazing how a few days of background thought can clarify a vexing problem. Chances are, you have figured out a better, cleaner way to do it. If you haven't, that's when you engage the help of a fellow programmer, a mentor, or you bring it up at the standup, code review, etc.

p.s. If only 20% of your coding is "easy", then you or your code base have a problem...

Benjamin Gruenbaum
  • 5,167
  • 4
  • 24
  • 34
user949300
  • 8,823
  • 29
    The "TODO comment" can be a great accelerator if you use it not only for "obscure edge cases" but really any piece of functionality that you can get away with postponing because no one's pinging you on Slack asking about it right NOW – Alex R Apr 09 '22 at 07:22
  • 4
    I second the TODO notation. Other good options are FIXME for known issues (e.g. "FIXME this code breaks if this edge case occurs") and XXX for "dirty" code (e.g. "XXX this is inefficient because xyz, but it gets the job done"). I also sometimes use NOTE for warnings or explanations to future devs, though I've only sometimes seen syntax highlighters recognize this one. Leave breadcrumbs for resolving the technical debt you make. – Drake P Apr 10 '22 at 23:42
  • 10
    I haven't seen a project where the TODO comments are actually fixed later – Lauri Harpf Apr 11 '22 at 08:37
  • 18
    This leads to 10+ year old TODOs scattered throughout the codebase. – xehpuk Apr 11 '22 at 09:43
  • 8
    @LauriHarpf: actually the only TODO comments which you find in an old codebase are the ones noone cares to fix. The ones which were fixed are usually deleted from the code, so you don't find them except in the VCS. – Doc Brown Apr 11 '22 at 15:08
  • @LauriHarpf I haven't seen them where you get sprint time allocated to it, but I have certainly seen it where it's taken into consideration when planning something. – corsiKa Apr 11 '22 at 17:14
  • 2
    +1 to the idea of "It's amazing how a few days of background thought can clarify a vexing problem" – laike9m Apr 16 '22 at 22:14
  • @xehpuk If you always link TODO with a bug, then use proper ways to prioritize/resolve bugs, you're good. The leftover TODOs are mostly of low importance. – laike9m Apr 16 '22 at 22:15
  • 3
    This is indeed good advice. Instead of a TODO comment (and depending on the level of abstraction the of the topic) one could also add a low or medium priority ticket in the team's issue tracker for the part of the task one cannot solve immediately, or add an entry into the backlog, if the team works in a scrum-like way. That avoids tons of TODOs in the code. – Doc Brown Jun 08 '22 at 16:54
  • ... and I would like to add that the described process is simply the application of the YAGNI (yet!) principle. – Doc Brown Jun 08 '22 at 16:56
  • 1
    A command/script to find and list all of your TODO comments is also very helpful! – Kenny Evitt Jun 22 '22 at 14:34
  • 1
    @KennyEvitt you can find extensions for your IDE that do exactly that. In fact I've installed one after reading your comment. Thanks! – Tadeo Jun 23 '22 at 00:00
  • 2
    As said about TODO's, if they do not get fixed, its because they does not create enough problems to get fixed, which for the method of quick and dirty means, does not need fixing. But having the TODO also means than next time you poke there you at least know about it, and can decide if the new feature NEEDs this or even solves the TODO :) – David Mårtensson Jun 23 '22 at 14:20
  • @DavidMårtensson Yup! – Kenny Evitt Jun 23 '22 at 16:01
  • @Tadeo I invested a little time figuring out how to use find and grep to write some handy little shell scripts for doing various kinds of 'text searches' (and also do nice things like, e.g. exclude 'build' directories from the 'search candidates'), but extensions can work great too! – Kenny Evitt Jun 23 '22 at 16:03
  • Speaking of TODO comment, I often use a variation like TODO_PRINT_MODULE, #ifdef OBSOLETE_PRINT_MODULE when doing major changes for a somewhat large features (a few weeks of work). One benefit, is that you can put those comment when you see something that need to be fixed but you don't want to do it right now. – Phil1970 Jun 23 '22 at 22:27
50

Whether one works clean or dirty is more a question of developer attitude and abilities, and the same holds for coding speed - this is rarely a deliberate decision people make.

Of course, there are devs who appear to work overly slow because they tend to be overly clean. But I have never seen a dev in my life who was really quick because their code was dirty. I have met devs who believed they were quick, but their dirty code haunted back at them the first time a tester or user tried to work with their mess. These devs may got the code quickly out of the door, just to get an even quicker phone call from a person who stumbled over the first few errors and made them clear their work wasn't finished.

Hence the idea of

a tool in my arsenal, to be able to code quick at the expense of dirty, to be able to choose when to use it

is IMHO flawed. The sweet spot for being quick is not "dirty", the sweet spot is found by

  • being clean enough, but not being excessively clean

  • invest enough time into proofreading and testing, because saving time by leaving these steps out never works

  • knowing when to stop with unnecessary abstractions

  • knowing which requirements have to be solved now, and stop worrying about "requirements which may or may not arise within the next ten years", which one actually cannot foresee.

Doc Brown
  • 206,877
  • Often, you can't even forsee requirements which may (or may not) arise next year, let alone the next ten years. – Zakk Apr 09 '22 at 22:39
  • 2
    Really, the knowledge of which requirements are "May or may not arise within the next ten months" is a more likely ballpark for most developers (Especially junior or intermediate, and Agile tends to make this harder for everyone, given the flexibility to change future requirements) - but the important aspect is realizing that as you shorten your forward thinking of requirement views, your code may end up becoming dirtier as a result. – Alexander The 1st Apr 10 '22 at 01:45
  • 7
    @AlexanderThe1st: your sentence "Agile tends to make this harder" sounds like a pretty huge misunderstanding of cause and effect. And my point above is about wasting time for "hypothetical requirements" which never arise, this was about losing coding speed, not about "clean vs. dirty". In fact, some devs tend to justify overengineered solutions by calling their code "extra clean", but missing that they did just waste time for things which cannot be foreseen. – Doc Brown Apr 10 '22 at 06:04
  • @DocBrown: That's a fair point about the cause and effect; my main reason about Agile making this harder is not that it causes it to be harder, but that the fact that stakeholders have feedback means they might want an item entirely changed - which, if the feature was prepared for too strongly in a different matter (If, say, it's an integration feature with another internal product that develops a little differently), you might end up with re-building the feature and having old references that weren't detailed out at the time of the old code development (That should be cleaned up/). – Alexander The 1st Apr 10 '22 at 06:21
  • 2
    @AlexanderThe1st Agile just isn't the fastest way to do development when compared with doing the exact same thing in a waterfall way. The reason why agile is "faster" is because waterfall wastes a lot of time continuing to build stuff even after it's been realized that it was a bad plan. The problem arises when people don't give proper respect to this--when they expect the agile developer to deliver in one week the same amount of project as the waterfall developer delivers in one week, agile is just slower on that time scale. – user3067860 Apr 15 '22 at 22:57
  • @user3067860: That's true - my point is more that if you, in Agile, try to do waterfall preparing, you don't get as much "Continuing to build stuff after it's been realized it was a bad plan", but "Stuff that we thought was a good plan abandoned in favour of a better plan.". Agile recognizes that it's harder to predict the future requirements - leading to making it harder to try and over-engineer early requirements and thus making it faster as a result, because you'll only build what you know won't change in the current timeframe. – Alexander The 1st Apr 15 '22 at 23:10
  • 1
    Quick and dirty can be faster for the first implementation, but it almost invariably adds cost to any followup work on the same code, even if none of the problems are visible to the users. Like copy/pasting and changing one instead of refactoring to handle both. For the first instances its fast, but once you need to change something for all cases, its no longer fast and you probably introduce more bugs. – David Mårtensson Jun 23 '22 at 14:29
  • I think this answer is good for new code, but doesn't help me cope with existing code. When coming at an existing "bad" codebase that lacks safety measures (usually encapsulation), this doesn't provide a methodical way of tackling it, thus I can't accept. – Gulzar Nov 22 '22 at 09:48
31

I am looking for methodologies which can be followed in order to optimize speed, even at the expense of code-quality, and the accumulation of technical debt.

Sure, here's the list of all the stuff that's forbidden to do in our team. All of these will improve initial development speed at the cost of other factors:

  1. Don't test edge cases. Reduces the time spent on testing.

    Drawback: Increases the time spent on customer support, debugging and bugfixes. Also reduces customer satisfaction.

  2. Copy & Paste. You need a method that's similar to one that's already been written? Instead of generalizing the old method or factoring out stuff that you can re-use, just copy and paste the whole method and make your modifications. Don't bother to remove dead code.

    Drawback: More technical debt. Bugfixes and later modifications will need to be done multiple times.

  3. Mix your layers. UI layer, business logic, data access layer? Forget it, just put the message box where you need it at the moment.

    Drawback: Moving to different UI framework or a different database backend will be impossible without a complete rewrite. Forget about being able to write unit tests.

  4. Don't think about good names. I spend a lot of time finding good clear names for methods, variables and classes. Just call them x, helper and var42 and spend that time coding instead of thinking.

    Drawback: People having to modify your code will hate you. With a vengeance.

  5. Don't write documentation or comments. It was hard to write, it should be hard to read.

    Drawback: Technical debt. Increases the time required to read and understand the code in the future.

Heinzi
  • 9,748
  • Does tese really make you faster? Not being able to read my own code, or having to do things several times makes me slower already in the same coding session! Could you maybe give an example of when this can be clearly applied? – Gulzar Apr 09 '22 at 09:58
  • 11
    @Gulzar: From personal experience in writing both production-quality and single-use throwaway code: Yes, they do make you faster - initially. As you correctly point out, dirty coding can come back to haunt you much sooner than you'd expect. And, obviously, the long-term cost usually outweighs the short-term gains by a large factor. In fact, the only legitimate use case I see for these techniques would be small, time-critical emergency hotfixes (system is down and customer loses $$$ per hour), but even then I'd try to replace it with a clean solution as soon as possible. – Heinzi Apr 09 '22 at 11:19
  • 8
  • But don't attempt to obtain 100% code coverage either. You won't get it. There is a sweet spot for testing; write enough tests to demonstrate that the code works, and no more than that.
  • – Robert Harvey Apr 09 '22 at 12:02
  • 6
  • Copy/pasting code and modifying it is absolutely the right thing to do in many cases. DRY can be taken to absurd extremes that waste time, make the code more complex and difficult to read, and do nothing to improve the overall architecture.
  • – Robert Harvey Apr 09 '22 at 12:07
  • This is YAGNI, although I'm not sure your example is a great one. In general, message boxes are the most expensive UI element there is, from a user perspective; I try to avoid them whenever possible.
  • – Robert Harvey Apr 09 '22 at 12:09