Showing posts with label le chatelier. Show all posts
Showing posts with label le chatelier. Show all posts

fishing and refactoring: A story with two endings

The Happy Ending

I'm salmon fishing on the River Spey, on the beautiful Tulchan beat, concentrating on spey casting. My phone is back at the hotel. My laptop is back at the hotel. I'm not thinking about coding. I'm fishing and I'm only fishing. Suddenly, from "nowhere" my subconcious pops an idea up into my consciousness. It says, hey, you know that code you were working on 2 weeks ago...? Where you had that nagging feeling there was a better, simpler solution? I know you know what I'm talking about! We'll I've been working on that for you. And I've come up with this. Here's the idea. Tada. What do you think?

For a moment, I think about the idea. It seems a good one. Of course, I can't try it out now because I'm waist deep in the middle of the River Spey. I promise myself I'll look into it when I get back to the hotel. I carry on trying to catch a salmon.

Later, back at the hotel I try out the new idea. I re-run all the unit tests and they pass. I make the change.

A few weeks later I'm fishing again. This time on the River Tay at Dunkeld. My subconscious pops up a new idea. I make a note of it. In the evening, back at the hotel I try the change. All the tests pass. The change is live.

A few weeks later I'm fishing again. On the River Verdal in Norway. My subconscious pops up with another new idea...


The Sad Ending

I'm salmon fishing on the River Spey, on the beautiful Tulchan beat, concentrating on spey casting. My phone is back at the hotel. My laptop is back at the hotel. I'm not thinking about coding. I'm fishing and I'm only fishing. Suddenly, from "nowhere" my subconcious pops an idea up into my consciousness. It says, hey, you know that code you were working on 2 weeks ago...? Where you had that nagging feeling there was a better, simpler solution? I know you know what I'm talking about! We'll I've been working on that for you. And I've come up with this. Here's the idea. Tada. What do you think?

For a moment, I think about the idea. It seems a good one. Of course, I can't try it out now because I'm waist deep in the middle of the River Spey. I promise myself I'll look into it when I get back to the hotel. I carry on trying to catch a salmon.

Later, back at the hotel I think about the new idea. I'm wary of making the change. There are no unit-tests I can quickly run. I'm remembering a few months back - that time when I tried an idea and broke stuff and was castigated. I'm fearful of making the change. I don't make it.

A few weeks later I'm fishing again. This time on the River Tay at Dunkeld. My subconscious gives me a new idea. I make a note of it. In the evening, back at the hotel I think about making the change. There are still no unit-tests. And I'm still remembering that time a few months back - when I tried an idea and broke stuff. Boy was I ridiculed. And if anything the culture is a bit worse since then. I can feel the fear. Once again I decide not to make the change.

A few weeks later I'm fishing again. On the River Verdal in Norway. This time, my subconscious doesn't pop up a new idea.

systems thinking slide deck





Here are the slides for the talk on Systems Thinking that Niklas Bjornerstedt and I did in the Scotsman pub in Oslo yesterday. The point about "Your wife is very beautiful" is that it is very easy to read that in a static sense. To get a sense of reading it in a more dynamic (relative) sense, imagine if someone replies "compared to who?!"

The books mentioned in the talk are:
The Law of Unintended Consequences slide has three images for these three stories:

local optimization, global pessimization

A well known UK company, let's called them B&O, sells bidgets and odgets. B&O sold me a bidget a few years back. They did a good job. I like the bidget they sold me. It works well. B&O rings me know-and-then to ask if I'm thinking of buying another bidget or my first odget.

Recently B&O rang me and I mentioned I was indeed thinking of buying an odget to go with my bidget. The B&O person on the other end of the phone sounded very pleased and arranged for a B&O salesman to visit me to provide me with an odget quote. On the designated day, at the designated time, the B&O salesman, let's call him Stan, arrived.

Stan didn't know that someone at B&O had spoken to me on the phone and arranged for Stan to provide me an odget quote. So I explained, for a second time, the odget I was thinking of, and where it would go and how big it would need to be. Stan said that he could quote for the odget, but, being honest, there was no point. Since the odget I was after was not a regular odget B&O would simply subcontract the work to a builder, and then charge me the builder's cost plus a fat markup. Stan said I'd be much better off hiring a builder myself.

Stan explained that the people at the B&O office get a cash bonus each time an odget quote is made to a prospective customer. Stan further explained that they got this cash bonus regardless of whether the customer actually bought the odget. Predictably, the people in the B&O office work hard to get quotes out. They send B&O salesman out to any and all jobs regardless of how likely the job is to result in actual work. Stan said if a B&O phone-handler phoned me to ask whether I'd received a quote, he'd very much appreciate it if I said no I hadn't because I'd changed my mind and didn't want an odget.

Top marks to Stan. No marks to B&O.

The Systems Bible

is an excellent book by John Gall (isbn 0-9618251-7-0). As usual I'm going to quote from a few pages:
Systems don't appreciate being fiddled and diddled with. They will react to protect themselves.
Systems tend to oppose their own proper functions.
Perfection of planning is a symptom of decay.
People in systems do not do what the system says they are doing.
The system itself does not do what it says it is doing.
To those within a system, the outside reality tends to pale and disappear.
Specialized systems select for specialization.
A complex system that works is invariably found to have evolved from a simple system that worked.
Experience isn't hereditary - it ain't even contagious.
The meaning of a communication is the behaviour that results.
Information theory is a mathematical treatment of what is left after the meanings have been removed from a communication.
Just calling it "feedback" doesn't mean that it has actually fed back. To speak precisely: It hasn't fed back until the system changes course. Up until that point it's merely sensory input.
Most of the parts are needed primarily as correctives to the vicious tendencies of the other parts.

Important - do not rub off

In one of his books Jerry Weinberg mentions a cleaner who wasn’t allowed to wipe the whiteboards. The story conjures familiar images of whiteboards full of stuff labeled “important - do not rub off”. It’s likely the stuff has lain untouched on that no-longer-white-whiteboard for weeks or months. It’s no longer important but there it stays, filling the whiteboard. A whiteboard full of stuff discourages its use in exactly the same way an empty whiteboard encourages it. And a whiteboard with the words “important - do not rub off” positively discourages use. It's really saying "keep away".

The whole purpose of whiteboards is that you wipe them. Perhaps they should be called wipeboards! Buying a wipeboard and its special pens and its special erasers and then filling it with stuff just the once is silly and expensive. If you want something permanent why not use a permanent pen on a big piece of paper stuck to the wall?

Filling a wipeboard with stuff labeled “important - do not rub off” is also silly if the stuff genuinely is still important. Someone might be desperate for a wipeboard and decide their new definitely-important stuff is more important than somebody else’s existing possibly-important stuff. So they wipe it. Wipeboards are so easy to wipe after all!

Le Chatelier's Principle says "[good] systems tend to oppose their own proper function". What is the proper function of a wipeboard? To be written on. How do you oppose being written on? Simple - wipe them completely clean every so often. Ruthlessly. Even if someone's written "important - do not rub off" on them.

With this use-clean use-clean use-clean dynamic set up the wipeboards give a clear visual impression of their dynamic use since anything on a wipeboard must necessarily have be written fairly recently. If they remain mostly unused most of the time you get to see that very clearly too.

Le Chatelier's Principle revisited

I was chatting about Le Chatelier’s principle with Hubert Matthews at an accu meeting in London yesterday evening. Hubert is a very smart guy and explained to me that losing your boarding card is a nice example, but not necessarily of Le Chatelier’s principle. What did I misunderstand?

Le Chatelier’s principle says "systems tend to oppose their own proper function". I incorrectly read this as a description of a poor system, an unorganized system, a system with no feedback, no control, (you get the idea), a system straying further and further out of balance at the slightest touch. In other words the system opposes its own proper function - but only in the sense that it never really had a chance of functioning properly in the first place! A system likely to die a quick natural death. That was the kind of systems behaviour I was looking for a name for. But I’ll come back to that.

So what is Le Chatelier’s principle really saying? As always an example helps. Every cell in your body requires a constant supply of glucose for energy. If your blood sugar level rises (e.g. after a meal) special cells in your pancreas produce insulin. Insulin causes the liver and muscles convert the extra glucose to glycogen and store it away, helping to reduce blood sugar levels. This is normal functioning. This is proper function. Ok. Now, what Le Chatelier’s Principle says (assuming I've got it right this time) is that your body will oppose this proper function! And your body does indeed start this opposition, and for a very good reason – if the insulin is left unchecked it continues to drain glucose from the blood and your blood sugar level gets too low. So when this happens different special cells in the pancreas start to produce glucagon. The glucagon works in opposition to insulin, causing the liver and muscles to convert the stored glycogen back into glucose thus increasing your blood sugar level.

In a healthy person these mini-systems operate quite properly, just like a thermostat, keeping your blood sugar level safely between fairly strict limits. Not too much (hyperglycemia) and not too little (hypoglycemia). They do this by opposing each other. It reminds me of the Goldilocks Principle. Goldilocks didn’t like the bed too soft or too hard, or the porridge too hot or too cold. Goldilocks knew her own mind.

So what have I learned from this? I’ve learned that I understand Le Chatelier’s Principle a bit better if I reword it ever so slightly to start with the word good. Good is a bit weak but I’m a bit pushed for time so it will do for now.

So what is my boarding card example an example of? Does The Inverse Le Chatelier’s principle apply? If a system does not oppose its own proper function is it more likely to be a poor system? I think there's an element of truth to that. If so we have Le Chatelier’s Principles. There are two of them, in opposition to each other, which somehow feels appropriate!

Good systems tend to oppose their own proper function.
Bad systems tend not to oppose their own proper function.

Thanks Hubert.

Le Chatelier - Systems tend to oppose their own proper function

One of the principles of Systems Thinking is Le Chatelier's Principle.

Systems tend to oppose their own proper function.

A nice example of this is checking your passport and boarding card at the airport. The comedian Michael McIntyre has a very funny sketch pretending to walk through an airport. Every three or four paces he has an uncontrollable compulsion to check that his passport and boarding card are still in his breast pocket. At one point he thinks he's lost them and goes into a mild panic.

Your passport and boarding card are completely safe in the pocket. They are not going to suddenly jump out of the pocket all by themselves. Gravity is not suddenly going to go into reverse. You're unlikely to start walking around on your hands. Pretty much the only way they're going to get out of that pocket is if you take them out yourself. Which is exactly what you do to check you haven't lost them!

On more than one occasion I've seen someone unknowingly drop their boarding card while checking they still have it. This is Le Chatelier. You have a goal in mind, you act to achieve that goal, and your action creates the opposite effect!

So now you know about Le Chatelier. You know that the time you're most likely to lose your boarding card is when you check whether you've lost it. So immediately after checking it you'll remember this blog and start to worry you lost it when you checked it. You'll probably have to check it again. Very soon you'll be checking it every three or four paces like Michael McIntyre. And of course, the more you check it the more likely you are to lose it! Le Chatelier again!

UDPATE: Losing your boarding card is NOT an example of Le Chatelier's Principle. It's an example of a different Systems Law: The Law Of Unintended Consequences! See Le Chatelier's Principle Revisited for what Le Chatelier's Principle really is (I think!)