What is like programming?

Wildbill

Ars Praefectus
3,327
Subscriptor++
I asked this on the Arduino forum, but no-one had a good answer. I'm coming up empty too.

In my experience, once programmers know what they're doing, they love to test their code as often as they can when writing it. If I've written twenty lines of code that I can't test, the next ten are going to be ensuring that I can. Folks new to programming treat the process like writing a book. Write it all. Test it. Cry when nothing works. It feels like you have to go through this rite of passage before you reach enlightenment.

But suppose you wanted to try and help a new programmer. You would want to say "No, it's not like writing a book, it's like X. You do it little by little". What's X though? Aye, there's the rub. You can't test four legs that'll one day be a table. You can't test a half cooked souffle. You can't test a shoe while it's still on the last.

What in the world do you do in incremental steps where testing can happen all the way along?
 

Lt_Storm

Ars Tribunus Angusticlavius
21,357
Subscriptor++
Perhaps painting a mural? You paint a little, but you are so close that you can't see the whole thing so every so often you have to step back and see how that little fits in with the rest...

Alternately, math: it's pretty important to check your intermediate steps fairly frequently so that you don't find your mistake in the second calculation only after you have finished all the work and now have to do it all over again.
 

Apteris

Ars Tribunus Angusticlavius
9,591
Subscriptor
From the book author blog posts I've read, writing a book also involves a lot of revisions, and the author also often writes it "little by little". (Some authors are struck by inspiration and pour out their story onto the page. I don't have numbers on how often this happens, but I know it happens in programming as well.)

Oh, also, I'm not sure "write a little, test a little" is the only way to write good software.
 

ramases

Ars Tribunus Angusticlavius
9,022
Subscriptor++
From the book author blog posts I've read, writing a book also involves a lot of revisions, and the author also often writes it "little by little". (Some authors are struck by inspiration and pour out their story onto the page. I don't have numbers on how often this happens, but I know it happens in programming as well.)

Many "inspired writers" will first write down a rough manuscript that contains the high points and key plot; this is the "what do I want to tell". Then, they will go through individual chapters and work on the prose, roughing out edges, fleshing out details, and so on; this is the "how do I want to tell it". As they write it, they will give individual chapters to friends, other authors they have a working relationship with, and their editor (at least the lucky ones that have access to one) to read and give feedback how they like it.

Often this detail work will result in significant changes to the plot, as they discover that fleshing out the details in one part requires jetisoning a side thread to create room in the book, or that something, while interesting, just doesn't work, or because it requires specialised typesetting that isn't in the budget[0], or a whole host of other reasons.

I'd say that this workflow has more than a passing similarity to how architectural work and detail implementation work can mesh together in software engineering.

[0] As an example, the Esper (telepaths) dialogues in Alfred Bester's "The Demolished Man" have a special typeset that "weave" individual contributor's talk together. Since part of the plot is that the stronger an Esper's mental abilities are the more complex weaves they can participate in, and that strong Espers need to restrict themselves when the conversation involves weaker Espers, a loss of this typesetting would lead to loss of significant plot context.

Oh, also, I'm not sure "write a little, test a little" is the only way to write good software.

I happen to agree; it can be a reasonable approach depending on the context. On others, it requires larger units of work, or work where meaningful tests are more involved. For example last week I wrote a dispatcher where individual jobs can control creation and fan-out of follow-up jobs (of whom they only know their name and required input values) through their return value.

It's not big, a couple hundred lines of code, and while some of it is amenable to unit testing, other concerns like making sure it works on all standard JDK executor implementations, simply cannot be tested in isolation.
 

Apteris

Ars Tribunus Angusticlavius
9,591
Subscriptor
[0] As an example, the Esper (telepaths) dialogues in Alfred Bester's "The Demolished Man" have a special typeset that "weave" individual contributor's talk together. Since part of the plot is that the stronger an Esper's mental abilities are the more complex weaves they can participate in, and that strong Espers need to restrict themselves when the conversation involves weaker Espers, a loss of this typesetting would lead to loss of significant plot context.
While I was aware that the medium always influences and becomes part of the message[1], this still blew my mind a little. Thank you.

[1] Nicholas Carr's The Shalllows is a good book.
 
...once programmers know what they're doing, they love to test their code as often as they can when writing it.
Not IME, but a portion of that would come from pressure to deliver.

"what is like programming?"

Baking? Baking is science, but there's room for creativity and individual need and/or expression. Baking produces something consumable by yourself or others, for thorough testing, revisions, and alterations. Like source code, recipes can be lost and there's means to decompile. Artistry is also appreciated in baking, on a variety of levels.

Books tend not to tolerate plagiarism ;)
 

Aleamapper

Ars Tribunus Militum
1,624
Subscriptor
...once programmers know what they're doing, they love to test their code as often as they can when writing it.
Not IME, but a portion of that would come from pressure to deliver.

"what is like programming?"

Baking? Baking is science, but there's room for creativity and individual need and/or expression. Baking produces something consumable by yourself or others, for thorough testing, revisions, and alterations. Like source code, recipes can be lost and there's means to decompile. Artistry is also appreciated in baking, on a variety of levels.

Books tend not to tolerate plagiarism ;)
Programming is like baking, except you're not making a wedding cake from scratch, you have to make it out of a birthday cake your friend who can't cook made two months ago. Also by mistake he used salt instead of sugar in the filling so you're going to have to scoop that all out and do it again. Also the kitchen scales are permanently tared to -163g and the oven either bakes at 100ºC or 240ºC, nothing in-between. Also the couple wanted an ice cream statue of themselves carved on top but no matter how many times you explained that it would melt during the ceremony they would just insist you 'find a way to make it work', and whenever you tried to talk to them about guest's allergies and dietary requirements they'd just argue about wether or not to they wanted bunting around the tables.
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
Programming is like baking, except you're not making a wedding cake from scratch, you have to make it out of a birthday cake your friend who can't cook made two months ago. Also by mistake he used salt instead of sugar in the filling so you're going to have to scoop that all out and do it again. Also the kitchen scales are permanently tared to -163g and the oven either bakes at 100ºC or 240ºC, nothing in-between. Also the couple wanted an ice cream statue of themselves carved on top but no matter how many times you explained that it would melt during the ceremony they would just insist you 'find a way to make it work', and whenever you tried to talk to them about guest's allergies and dietary requirements they'd just argue about wether or not to they wanted bunting around the tables.

Oh rubbish, that's not what it's like at all. Oh wait, actually it's exactly like that ;) Except that as described, the project seems too easy.

What I was looking for was an analogy that helps beginners understand that writing your entire program and then indulging in some 'big bang' testing rarely goes well.
 

Aleamapper

Ars Tribunus Militum
1,624
Subscriptor
In that sense I think baking is the perfect analogy - as long as you keep tasting your food as you make it, you can add a little salt, add a little water, turn the oven down or whatever and everything will probably turn out ok, but if you just make the whole thing without tasting anything along the way and at the end realise you forgot to put any sugar or salt in the pastry, you're kinda screwed.

Unfortunately I think shortening of feedback/testing loops is something most devs don't take on board until they've personally been bitten *hard* by not doing it, and you won't know you've been bitten hard until you know what it's like to not be bitten at all.
 

LordFrith

Ars Legatus Legionis
25,252
Subscriptor++
For some reason, when I'm coding, I always have a mental model of myself sculpting clay. It starts off as a blank medium, and you smoosh it here and there, take some off, put more on, move this way, realize that what you have is garbage and smoosh it all down again, starting over in the parts, you can never quite be done, but you have to stop somewhere... but there's always that last little bit to do, and it will be perfect....
 
The programming I do is usually modular by its nature. I usually address it as a top down process where I develop the design/outline/architecture first and think about how the different pieces will fit in. The low level pieces are generally self contained. Consequently it requires testing of the different pieces and then integration testing to see how the sperate parts work together. That makes me think of it as building a machine by connecting the different pieces of the system. Once I get the whole thing working I start refining the pieces.
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
The programming I do is usually modular by its nature. I usually address it as a top down process where I develop the design/outline/architecture first and think about how the different pieces will fit in. The low level pieces are generally self contained. Consequently it requires testing of the different pieces and then integration testing to see how the sperate parts work together. That makes me think of it as building a machine by connecting the different pieces of the system. Once I get the whole thing working I start refining the pieces.

We have a winner! Or at least, the best so far. In a manufacturing plant with many steps in the process, I would expect that each step would be tested independently. It would be crazy to build the whole line and try it out by saying "Let 'er rip Clyde!".
 
In that sense I think baking is the perfect analogy - as long as you keep tasting your food as you make it, you can add a little salt, add a little water, turn the oven down or whatever and everything will probably turn out ok, but if you just make the whole thing without tasting anything along the way and at the end realise you forgot to put any sugar or salt in the pastry, you're kinda screwed.
Cooking (as in stovetop or whatever) is more like this, IMO. Baking... there's very little taste testing involved with the dry ingredients, only the wet, and once it's in the oven if you didn't get the mix right you're boned because the chemical reactions have already taken place. Once it's out of the oven, it's completely spoiled if you realized you totally forgot to put in salt, but you can add it at the end while cooking.

With cooking, you can keep adjusting ingredient ratios right up until it's served on the plate. The actual cooking process can be adjusted unlike baking where you mainly have control over temperature and that's it: you can stir differently, or not at all, you can move it to a different burner, change the temperature, let it simmer over many hours or boil for minutes, make a reduction of the sauce, flambe, run cold water over pasta, etc, etc. You don't get that fine-grained control when baking. Plus, more relevant to the OP's post, taste testing as you go along both by yourself and with others is one of the best parts. :) It's so crucial to cooking that in the Islamic faith, during fasting, there's an exception carved out for people who are cooking: they're explicitly allowed to taste the food they are cooking.
 
For some reason, when I'm coding, I always have a mental model of myself sculpting clay. It starts off as a blank medium, and you smoosh it here and there, take some off, put more on, move this way, realize that what you have is garbage and smoosh it all down again, starting over in the parts, you can never quite be done, but you have to stop somewhere... but there's always that last little bit to do, and it will be perfect....
lol, I totally know that feeling, especially if it's a personal project. There's always that little bit extra you can do to make it better.

Which is why we end up with consumer products that move around interface elements from major version to major version for seemingly no reason. :mad:
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
Well, there's basically two ways to program. The first is to think of what you need and then build the whole thing from the ground up, so you have nothing until you have everything. The second way to approach the task is to make something simple, and then keep improving it.

Obviously in both cases when you're finished, you need to test whether the whole thing solves the whole problem correctly. Such complex tests aren't easy, but they are straightforward.

If you build something large from small parts, it helps to know that each part does what it's supposed to do. So writing test for each function or method makes sense.

If you're iterating and adding functionality as you go, the main risk is regressions. So here, you'll want to test against previous test cases and add new ones as you go.

In any event, you'll find most of the bugs quickly enough. The trouble is finding what causes them, and apart from that, making sure the end result is really correct.
 

William Wise

Smack-Fu Master, in training
61
Programming is like designing a recipe for a very, very stupid cook - Only that such cook has absolutely no problem doing everything you say, and is willing to show each result you give it multiple times, both successes and failures.

You usually start with the overall dish you want this cook to make, and look deeply in what you want it to look and taste like. Then you have to break down the steps and ingredients of the dish, and what you might have to make the cook do to follow each step. You give the cook 'test-steps' to see if it can do them the way you want it to - and if it doesn't, you must revise the step, and perhaps break it down into more steps in the recipe.

You go through this whole process again and again to make the braindead cook do very obscure, yet very necessary tasks for creating the dish. Such things grant you loads of knowledge for other recipes for this cook to produce.
 
Programming as a career is like spending your working life rolling a rock up a hill, except when you finally get to the top, you find out you've been pushing the wrong rock up the wrong hill. And then management tells you they wanted you to clean out the stables instead, but nobody bothered to tell you.

I'll take mixed analogies for $400, Alex? ;)

Which is very apropos of the software industry.

IME, its "we need to change the software to do X", "okay, here you go", "no, we meant Y", "okay, here's Y", "no we meant X and Y", "okay, here's X and Y", "no we meant X and Y except when Z", "okay, here's X and Y except when Z"... ad infinitum.

Or worse, "we need to change the software, we don't like the way it works", "what new behavior do you want?", "well, first we need to know how the current software works", "o_O wat?"
 
Programming as a career is like spending your working life rolling a rock up a hill, except when you finally get to the top, you find out you've been pushing the wrong rock up the wrong hill. And then management tells you they wanted you to clean out the stables instead, but nobody bothered to tell you.
Then you leave the rock precariously balanced at the top of the hill to go clean out the stable. Everyone forgets about the rock up there until it eventually comes rolling back down and smashes something.
 

Dan Homerick

Ars Praefectus
5,528
Subscriptor++
Riffing on UserJoe's "building a machine" answer (best one so far, IMO), I'd say programming is like building a factory. It has inputs, and outputs, and unlike baking, a factory is something that is rarely "done" -- at some point it starts being used, but change continues.

A factory is built by many people, and within it's walls exist many solutions to problems that have arose. Some are clever and well-refined, whereas others are dirty kludges that no one likes dealing with, but which keep the product flowing.

A factory can be gutted, can have whole lines within it be shut down (dead code), and can be expanded. It has documentation for how things are supposed to work, and occasionally even has docs for how things actually work.

It has workers, and parallelism, and efficiency concerns. Parts (data) need to be tracked and transported, and inputs need to be tested prior to use (or you can rely on spec sheets, if you're brave).
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
Riffing on UserJoe's "building a machine" answer (best one so far, IMO), I'd say programming is like building a factory. It has inputs, and outputs, and unlike baking, a factory is something that is rarely "done" -- at some point it starts being used, but change continues.

A factory is built by many people, and within it's walls exist many solutions to problems that have arose. Some are clever and well-refined, whereas others are dirty kludges that no one likes dealing with, but which keep the product flowing.

A factory can be gutted, can have whole lines within it be shut down (dead code), and can be expanded. It has documentation for how things are supposed to work, and occasionally even has docs for how things actually work.

It has workers, and parallelism, and efficiency concerns. Parts (data) need to be tracked and transported, and inputs need to be tested prior to use (or you can rely on spec sheets, if you're brave).

I like that. Works well and captures a few extra features that the other contenders didn't.

Unfortunately, it doesn't meet my super sekrit requirement: To be able to tell a novice Arduino programmer why they should test as they go instead using big bang testing at the end.

I think now, contradicting my OP, that it is like a carpenter building a table. You have to build a number of components (bits of wood) and after each cut you have the opportunity to test your work by measuring. You may assemble into sub-assemblies and bring everything together at the end.

It's not a perfect analogy by any means, but it's the best I can think of at the moment.
 

Lt_Storm

Ars Tribunus Angusticlavius
21,357
Subscriptor++
Riffing on UserJoe's "building a machine" answer (best one so far, IMO), I'd say programming is like building a factory. It has inputs, and outputs, and unlike baking, a factory is something that is rarely "done" -- at some point it starts being used, but change continues.

A factory is built by many people, and within it's walls exist many solutions to problems that have arose. Some are clever and well-refined, whereas others are dirty kludges that no one likes dealing with, but which keep the product flowing.

A factory can be gutted, can have whole lines within it be shut down (dead code), and can be expanded. It has documentation for how things are supposed to work, and occasionally even has docs for how things actually work.

It has workers, and parallelism, and efficiency concerns. Parts (data) need to be tracked and transported, and inputs need to be tested prior to use (or you can rely on spec sheets, if you're brave).

I like that. Works well and captures a few extra features that the other contenders didn't.

Unfortunately, it doesn't meet my super sekrit requirement: To be able to tell a novice Arduino programmer why they should test as they go instead using big bang testing at the end.

I think now, contradicting my OP, that it is like a carpenter building a table. You have to build a number of components (bits of wood) and after each cut you have the opportunity to test your work by measuring. You may assemble into sub-assemblies and bring everything together at the end.

It's not a perfect analogy by any means, but it's the best I can think of at the moment.

Right, because factories aren't tested before they are completed. The fact of the matter is that pretty much every other form of engineering involves building and testing huge numbers of models, all the components used in the factory by themselves, etc. In fact, they spend much more effort on that than we do when we test stuff as we go. Imagine building that factory without any testing and then trying to turn the completed factory on with no real idea if the bottling machine, conveyors, and mixers are fit for function. Hell, you don't even know the strength of any of the materials that go into making the machine (because you didn't test that). It's going to explode and probably kill someone.

Fortunately, software is usually slightly more friendly than that, you are unlikely to kill someone with most products. But, nonetheless, if you don't know the characteristics of the components you are using to build your machine, it will still explode messily in your face.

Of course, software is also different than a factory in one important way: it's moderately easy to change. So that means that the steel you used to make the bottling machine, well, someone could change its fundamental properties while the bottling machine is still spinning. As software engineers, we do this kind of thing all the time. The ability to do this kind of thing is one of the primary reasons that we use software rather than some kind of mechanical control system. But, it poses a special danger. Namely, if we change the physical properties of the steel that bottling machine is made of incorrectly, it might break suddenly while operating at full speed.

So, testing as you go is even more essential than it would normally be. After all, you need to make sure that when future you makes the mistake of accidentally turning that steel into putty (really, changing the cohesion has that effect? Who knew?), you find out about that mistake before the bottling machine explodes. This implies the following things for your arduino project: 1) you want tests that run every time that anything about your code changes. 2) Many or even most of those tests should run before the code even makes it onto an arduino. 3) You need to test the smallest element of the project you can manage, remember, you want to know that the steel you are about to use to make the bottling machine doesn't have the consistency of putty. So, test early, test often, and test automatically.
 

LordFrith

Ars Legatus Legionis
25,252
Subscriptor++
So for the sake of Arduino coding, it's like less the need for pure/true "unit tests" and more the case of "incremental development".

Let's say I want to control a servo with the ADC input that is reading a pot.

I could just code everything from the get-go. And the when it doesn't work.... what do I do?

Or, I could start with a component that generates a PWM waveform using the clocks. Then watch it with an oscilloscope.

Then I could change the values with different hard coded numbers, and see the waveform change.

Then I could add the ADC, and connect it to the PWM generator, watxching the waveform on the scope.

Then I could connect the PWM to the servo, and see it move with the ADC.

At each point, I can confirm I am seeing the behavior I expect, and at each point, I can debug against a previously working version.

In this way, ""What is programming like" is closer to "How would you bake a cake in a kitchen with no lights?"
 

Lt_Storm

Ars Tribunus Angusticlavius
21,357
Subscriptor++
So for the sake of Arduino coding, it's like less the need for pure/true "unit tests" and more the case of "incremental development".

Let's say I want to control a servo with the ADC input that is reading a pot.

I could just code everything from the get-go. And the when it doesn't work.... what do I do?

Or, I could start with a component that generates a PWM waveform using the clocks. Then watch it with an oscilloscope.

Then I could change the values with different hard coded numbers, and see the waveform change.

Then I could add the ADC, and connect it to the PWM generator, watxching the waveform on the scope.

Then I could connect the PWM to the servo, and see it move with the ADC.

At each point, I can confirm I am seeing the behavior I expect, and at each point, I can debug against a previously working version.

In this way, ""What is programming like" is closer to "How would you bake a cake in a kitchen with no lights?"

While this is often how Arduino projects get developed, it really isn't an ideal strategy. There is a reason that things like unit testing, continuous integration, etc. were all developed. That reason applies to an arduino project as much as it does to any other software project you might consider developing.

The fact of the matter is that, when developing, you want feedback on the metaphorical hardness of steel as quickly as you can get it. Sending your code to the device slows all that down. It means that you don't realize you made your steal into putty as quickly, and that means you don't learn as quickly and likely have more changes for the mistake to hide in. This is just as true of an Arduino project as it is of a Java based enterprise system.

Or, in short: best practices for software development are best practices for software development. The target environment for your code doesn't change them. Testing should be done in essentially the same way regardless of that.
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
Unit tests make sense of course.

Typical Arduino users are not going to go there though. The IDE doesn't have anything to support it that I know of and even if it did, it's way outside the kind of thing that those users are looking for. It seems as though most people posting are looking for basic coding help with an early project. In many cases, their only project for a while. TDD is a bridge too far.

TDD seems like hard work too. A lot of mocks. Most Arduino code is going to be touching the hardware. What's a sensible way to devise and execute tests in that situation? I'm not trying to rain on your parade here, I'd like some suggestions - how could it work well?
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
[url=/civis/viewtopic.php?p=39295776#p39295776:1wli45ed said:
LordFrith[/url]"
You can't easily check timing for tricky loops, but you can test various logic blocks if you do any sort of computation.

Sure. Computation is likely nothing though. The problems in Arduino world come when you draw too much current or try to step a stepper too fast or do something silly with delays. I can't see (but would love to be shown) how to write and execute tests for most of what an Arduino sketch does.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
Riffing on UserJoe's "building a machine" answer (best one so far, IMO), I'd say programming is like building a factory. It has inputs, and outputs, and unlike baking, a factory is something that is rarely "done" -- at some point it starts being used, but change continues.

A factory is built by many people, and within it's walls exist many solutions to problems that have arose. Some are clever and well-refined, whereas others are dirty kludges that no one likes dealing with, but which keep the product flowing.

A factory can be gutted, can have whole lines within it be shut down (dead code), and can be expanded. It has documentation for how things are supposed to work, and occasionally even has docs for how things actually work.

It has workers, and parallelism, and efficiency concerns. Parts (data) need to be tracked and transported, and inputs need to be tested prior to use (or you can rely on spec sheets, if you're brave).

I like that. Works well and captures a few extra features that the other contenders didn't.

Unfortunately, it doesn't meet my super sekrit requirement: To be able to tell a novice Arduino programmer why they should test as they go instead using big bang testing at the end.

I think now, contradicting my OP, that it is like a carpenter building a table. You have to build a number of components (bits of wood) and after each cut you have the opportunity to test your work by measuring. You may assemble into sub-assemblies and bring everything together at the end.

It's not a perfect analogy by any means, but it's the best I can think of at the moment.

A factory is a set of assembly lines. Each line takes some input, does some work on it, and produces some output. Some assembly lines feed into others, while others are self-contained.

Each assembly line is made of individual steps. Each step is an assembly line in miniature: it takes an input, does work, and produces an output.

Unit testing: each individual step of each assembly line would be tested for functionality: does this machine take parts A and B, orient them correctly, and weld them together correctly? That specific machine would be tested - by itself - on (potentially hand-crafted) parts of varying quality (and, in this metaphor, orientation), as well as with missing inputs. Once the individual machine is known to do its job correctly, it can be slotted into its spot in the assembly line.

Integration testing: once each individual assembly line is completed, it's tested from end-to-end, all by itself. In the inevitable "car" analogy, the "make a door" line would be run to make sure that a pile of door parts becomes a door that's oriented correctly at the end of the line.

System testing: once all of the assembly lines are in place, the factory will turn out a handful of cars that will serve to verify that everything's hooked up right. The cars won't be sold to customers, but will be sacrificed to acceptance testing. Testing here is "do I get a basically-car-shaped thing out, that weighs about right, etc.".

Acceptance testing: the first few cars off the line will be used in crash tests, run for hours (or days) solid, put through obstacle courses, etc., all to verify that the car, as produced by the factory, meets the requirements for a car that the factory's owners demand.

If the factory starts with system testing, determining why the passenger door was placed in the trunk will be incredibly difficult. If testing starts with acceptance testing, there's not enough money in the world to pay me to start that engine. But, if there's good reason to believe that each individual step in the process is working correctly and that the steps are put together correctly, well, I might send the first car through the crash test before driving off, but I'd at least sit in it right off the line.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
I'll just tack on here that analogies for software into the 'real' (physical) world are often tortured because they miss the point of software.

It is _really_ easy to try changing software (even if it's rubbish and full of tech debt, fundamentally you can try out changes to it *extremely* cheaply compared to the physical world (where a test either uses the real product, or requires a duplicate to be made).

Therefore any analogy involving the incremental capabilities inherent in software is likely to have issues. Be aware of that. This is why the Math example posited up thread is actually a really good one in many respects, because while it is limited, it is also not flat out wrong in some respects as many others are (factories are ruinously expensive to expand once you hit your floor plan limits for example) and physically moving items to improve the flow of work would be expensive...
 

Jehos

Ars Legatus Legionis
55,560
I always think of it kind of like sculpting in clay. Make a little change, step back and look at it. Make another little change, step back and look at it. Sometimes you're adding things, sometimes you're subtracting things, sometimes you're changing the shape of what's there. You can always tear a chunk off and start over if you don't like it.

where a test either uses the real product, or requires a duplicate to be made
What, you don't test in production? Coward. :D