Sunday, 17 July 2016

On theory and practice

During the final year of my Zoology degree I was lucky enough to do my dissertation at Edinburgh zoo, studying communication between collared peccaries. At the time Edinburgh zoo was the only zoo that actually went into the enclosure with the peccaries. It turns out that the staff at the zoo aren't particularly keen on the students, seeing them as know-it-alls with no practical experience. Before I went into the enclosure I was made aware, by the keeper, that my classroom learning was worthless inside the enclosure and that I was to do exactly as I was told if I wanted to keep my access to the animals.

As our relationship thawed I found the keeper to be an absolute fountain of knowledge about the peccaries, their habits, quirks and behaviour. I found that my time working with the animals (I helped clean the enclosure, feed and tag them and help the vet when required) was where I really started to learn about behaviour. My classroom learning hadn't been a waste, it was just one part of a greater whole. It gave me a frame of reference from which to understand what I was seeing.

At that time I was heavily into the martial arts and I couldn't help but draw parallels. The drills and training sessions were an important frame of reference for me to draw on. They gave me a set of theoretical tools which I had to turn into a skillset or style that worked for me practically. I did that through trying these things in a practical setting (sparring, competition fighting and door work). This is almost always a one way process - if something doesn't work for you practically, then you adjust your frame of reference. The martial arts is a very good way of learning this one way rule. The consequences of trying to force your theoretical knowledge on to unwilling reality are usually immediately apparent (she can be a harsh mistress).

The point I am working towards here is that this is true of any endeavor. It really doesn't matter how beautiful your theory is, or how much it should work, if it doesn't match reality then it's wrong. Results (in a practical setting) or observations (in a scientific setting) always trump theory. Unfortunately it is really easy to fall in love with a theory and it's even easier to twist your view of reality to accommodate "glitches". However, I don't think there is a worse way to lose an argument than to have to run off with your tail between your legs when someone simply says "don't tell me you are right, show me".

As a quote on this subject, I particularly like this from an animal trainer Gary Wilkes:

Good science does not propose rules that are not confirmed by an objective observation of nature. Good science reveals nature as it is. If reality contradicts science, then it’s not really science.

Friday, 8 January 2016

Using an e-collar

Given that there is a movement in the Scottish government to ban e-collars (dog collars which beep, vibrate and give an electric pulse) I thought I would write something about how I have used them in training Bane and Silver. I am not writing from the perspective of an expert, but as a standard dog owner who wants to have well behaved and safe dogs.

First of all, it's worth saying that these collars are thought of as cruel and are often referred to as shock collars because of the electric pulse delivered to the dog. I think shock collars are exactly the right term for these training tools as they shock the dog out of whatever activity they are too intent on doing to listen to you. Unfortunately, the word shock also conjures images of people being tortured using car batteries or mains electricity. Having actually used the collar on myself I can confirm that it is the former rather than the latter (I would never use anything on my dogs that I'm not prepared to use on myself). The feeling is not in anyway painful, but it's a pulse that jerks the muscles and breaks your concentration.

I think of it this way - you need to use the minimum force necessary to break your dog's intensity so they listen to you. So, if I was fast asleep and you needed my attention it might be necessary to shake me. However, if I am concentrating on coding I wouldn't expect a work colleague to start shaking me to grab my attention when a simple "hello" would do the trick. It's also important to remember this is a training tool, it helps the dog to learn the required behaviour quickly and acts as a safeguard when things go wrong.

Here's an example of it's function as a safeguard from today's walk. I took the dogs out into the field I share with my 9 neighbours. It borders a public park with only a small fence in between. I put the collar on Bane because he's going to have a high intensity play - playing tug and chase with Silver and I don't trust other people not to let their dogs rush into our field. So, my dogs are being training to sit and stay while I throw a ball and they only fetch it on command. I've just let the dogs run for the ball when a lady walking her dog throws the ball right into our field. Her dog (a lab) rushes through the fence and starts charging towards Bane despite his owners command to come back. This is exactly how fights start. I called my dogs back and Silver returned, but Bane ran forward so I delivered a shock, Bane stopped and on command returned to me. I then put my dogs on place (a version of sit and stay that the dogs understand they must not move from regardless of what is happening) while I helped the lady get her disobedient dog back. The lab however had other ideas and his excitement had turned to aggression and he became quite challenging, so the shock delivered to Bane definitely stopped a fight.

It's easy to say "you shouldn't need to cruelly shock your dog to get it to behave", but this is the real world and I can't trust other people to control their dogs and create a safe environment for my dogs to have fun in. The point, however, is just that I used a training tool to help prevent something much worse from happening, which wouldn't have been necessary if the lab had been wearing a collar... Obviously I didn't just go out, buy a collar and start shocking Bane at random. I did it after being trained in it's use by a professional. I also didn't just settle for the first dog trainer I found. I went to a number of trainers (the first being a positive only trainer) and settled on Roddy Kirk (Be pack leader) after finally finding a trainer who had dogs that behaved the way I want my dogs to. It's quite an impressive sight watching a pack of 7 dogs walk down a narrow path way, see another dog approach and just separate to give the approaching dog plenty of space to pass by, then reassemble without a word of command.

Banning things isn't normally a good idea, but banning something that can be used to keep your dog safe is just plain stupid. I know the argument is that there are better ways to train your dog and therefore the collars are unnecessarily cruel. Neither of my dogs has ever shown the slightest disinclination to put their collar on. In fact Bane and Silver both love the collar, because they know that the collar means a high energy walk where they can run free. When I first got Silver, she had been badly treated and wet herself in fear when I took out a roll of tinfoil one day - thinking she was going to be beaten, yet she's never hesitated to put on her collar.

I put a lot of work into training my dogs so that they have the freedom to behave like dogs and have a happy life. I'm not an expert, so the training has been finding my way in the dark a lot of the time, but I guess that is true of the majority of dog owners. My experience is that most dogs simply aren't well trained and living next to a dog walking park I see a lot of bad behaviour. So in the real world it's nice to have a safeguard.

Saturday, 10 October 2015

BSL

Breed Specific Legislation

This is legislation enforced in the UK where your dog can be destroyed if it looks like a banned type of dog, regardless of it's actual breed or behaviour. This was introduced in 1991 as a response to several high profile dog attacks and an increase in the number of people using "prestige dogs" as weapons. I'm old enough to remember the media stories at the time.

Obviously there are two emotional sides to this legislation. In my view there's the "I'm afraid of dogs and therefore they should be killed so I can feel safe" argument (spoiler: I'm on the opposite side). Then there's the "I want a pitbull" argument. Unfortunately, in any discussion which has it's basis in emotion, it's impossible to convince the opposing side. I can't cure your fear of dogs, you can't stop me wanting one...

  • Are you seriously asking me to put my child's life at risk for the sake of your dog????
  • But your child isn't at risk from my dog...
  • YOU CAN'T KNOW THAT
  • My dog loves children, he's super gentle with them
  • WON'T SOMEBODY PLEASE THINK OF THE CHILDREN
  • Your dog might not kill children, but some people make their dogs aggressive. You can't argue that bigger dogs do more damage when they attack.

While while we continue the above argument ad nauseam, the dogs continue to die. Which is a shame, because we have a lot of evidence to show that BSL has been a complete failure in protecting the public. First off, "BSL has not succeeded in reducing dog bite-related injuries wherever in the world it has been enacted." National canine research council. If that's not enough of a blow to BSL, it's also not going to work in the future with some amendments because it's fundamental principle is wrong: "There is no evidence from the controlled study of dog bites that one kind of dog is more likely to bite a human being than another kind of dog. A recent AVMA survey covering 40 years and two continents concluded that no group of dogs should be considered disproportionately dangerous".

Unfortunately, the media has moved on from it's high profile cases of dog attacks, leaving in its wake new and harmful phrases like "large aggressive breeds". This means that stories about how the media portrayed dogs were completely wrong are very thin on the ground.

Despite the fact that we've a history worth of evidence to show that banning things is a terrible idea, we seem doomed to repeat the mistake over and over again. I find it soul crushing to think that we, as a society, look at a problem like "owners training their dogs to be vicious" and decide that eradicating the dogs is a sensible solution. That we would rather kill dogs than face our own fear of them. That we concentrate on "the dog problem" when we suffer 4 dog bite fatalities per year in the UK as compared to road fatalities in the thousands. No one has considered banning cars because it's simply not a workable solution...

I assume that during the talks prior to the introduction of the legislation someone must have said "Perhaps the problem lies in the owners, maybe we need to concentrate on the fact that society is creating people who want to hurt each other and are using dogs to achieve that goal". The fact that the lone voice of reason was lost in the desire to be seen to be doing something quickly is what really makes me sad.

Sunday, 28 June 2015

A year of Bane

Big decision

Almost a year ago, I set off to Leeds to buy a puppy. After an awful lot of research I decided that a presa canario was what I wanted after I fell in love with the dog in the link. I returned with Bane, my 8 week old puppy after a lovely day playing with all the puppies and falling in love with Major (Bane's dad) whose looks and personality make him the poster child for large, calm dogs.

Lots of people in my life were quite concerned about the large quadrupedal killing machine I was bringing home. Fortunately, after actually meeting him everyone has changed their minds. However, I took my job of raising Bane to be a calm, well mannered dog, quite seriously and began socialising him from day one. I have been really lucky to find an awesome group of people to walk and train Bane with. It's been great fun learning how to handle a large dog and I thought I would write up some of the things I've learnt.

Raising Bane

At first, I concentrated on teaching Bane the simple commands everyone does: sit, come, lie down, stay etc. As everyone seems to find out quite quickly, your dog will come to you 100% of the time inside the house or garden, but perhaps a little less than that when you actually want the to - like in the park! My socialisation seemed to have worked a little too well and Bane would be too excited about playing with other dogs to listen to me. So i got some private tuition for him from a fabulous dog handler. I learnt to control Bane's excitement before he got to the other dogs and show him how I wanted him to interact with other dogs. This meant I had to be super calm during the interaction and not tense in case Bane ran off playing with another dog. The best piece of advice I got during this phase was "put your dog in as many challenging situations as you can and will him to do his worst, then you can correct his behaviour". Having the confidence to let your dog make mistakes and knowing you have the tools to correct any unwanted behaviour really speeds their training up and I definitely believe it strengthens the bond between you and your dog.

A lot of the tools to correct your dogs behaviour seem centred around keeping your dog calm during a given interaction. Stopping Bane being excited and rushing over to meet a new dog has dramatically reduced the amount of times he gets told off by another dog and increases his ability to listen to me when I want him to come away. On the pack walks we go to, each one starts off with the reminder "excitement is the biggest cause of fights between dogs".

It takes two

The next phase in what was really my training, not Banes, was to realise that it's not all about my dog. Up until recently, I'd really focused on having Bane do what I tell him. However, I noticed that Bane was an absolute prince on the pack walks amongst lots of other well mannered dogs, but out in the real world, he was often attacked by other dogs or people would create confrontational situations with him. For example, a man once shouted at me to get my dog on the lead, because he didn't want his family to have to walk past my frenzied killing machine. I should point out that at that moment in time, Bane was away from the path, oblivious to what was happening, sniffing his way through the undergrowth. I reacted in my own standard way, by explaining that if the man continued to shout at me the dog would be the least of his worries. Bane immediately sensed the confrontation and raced over to protect me. He placed himself between me and the man and barked his warning. I slipped a lead on Bane and walked off, however, I later realised that I should have taken control of the situation earlier.

So now, when I walk Bane, my focus is less on controlling my dog in a difficult situation and more about managing each situation so that Bane can just act normally. I have found it to be a really effective method for having a nice walk and it's quite easy to do once you get past that typical British reserve. There's a tendency for two people walking past each other not to speak or make eye contact. I think this makes their dogs think that it's up to them to take the lead then. If the owner of the other dog is a bit afraid of dogs, this can make their dog more protective and less likely to be happy if Bane wants to say hello. So, rather than let the dogs take the lead, I'll give a smile and say hello, perhaps make it clear that Bane's friendly. If that relaxes the other person, the dogs will follow suit if it doesn't then I'll call Bane over and put him on the lead.

I've also found that asking someone if their dog is friendly is a good opener. If the owner greets you with a cheerful response, I've always found the following interaction between the dogs to be friendly. I've also found that it sometimes jolts the other owner into action, a couple of times I've had the response "she can actually be a bit snippy sometimes, I'll pop her on the lead mate".

Survey of one

Obviously, these are my thoughts having reared a dog to the grand old age of one :) so I'm not claiming they are universally true. I do however, thoroughly recommend pack walks, socialisation and not getting a dog unless you plan to spend lots of time enjoying it!

I feel I should mention at this point that I actually have two dogs now, Bane and the lovely Silver - who came pre trained. However, everything I've said about walking Bane seems to apply to walking Silver too, especially the parts about setting her energy levels.

Saturday, 5 July 2014

Past, present and future me.

I think more than is probably good for me. I think about conciousness, time and the nature of reality along with a whole bunch of other things. My current wondering is whether or not I can put into words my thoughts on what it is that makes me me. For what it's worth, I'm guessing the answer is no.

As an old person, I have a long and rich history of being me.

  • First there was baby me,
  • then child me,
  • teenager me,
  • 20's me (that guy! Ha, what a hoot),
  • 30's me,
  • more recent me,
  • there's right now me,
  • tomorrow me,
  • Monday morning me (man, I feel for that guy)
  • future me.

Of all those people, "right now me" is the guy I feel closest to. Having said that, I'd probably be prepared to put "right now me" to some small difficulty for tomorrow me, or even a probably future me. Looking back though, I barely remember baby me and I can certainly empathise more with people at work or my family than I can child me - which seems a little strange. Especially when you think that past me actually happened! My memories of past me are surely what go to create "right now me", future me, however, is just a figment of my imagination.

Past me

My brain makes sense of who, what and where I am from my memories. In a simple example, I can follow my train of thought in this blog because I remember why I wanted to write it, I remember sitting down with a cup of tea at my desk - causality is complete. It's easy to understand what happens when that breaks down too - when you walk into a room and forget what is was you went in for. Obviously, my relationship with me goes back further than that, I sat down at my desk to write this blog post with a cup of tea, milk and no sugar, because 30's Ant decided to stop taking sugar in his tea. In a less trivial and slightly more esoteric example, the way I deal with my colleagues at work is different to that of other people. It's different to the way 20's and 30's me did. But there's a fading silver thread that connects us - showing the evolution through time of right now me.

None of those past me's exist in anywhere but my memory and my memory is faulty. I know this because other people's rambling stories about 20's me don't really gel with the handsome young rake I recall. Also - science says it's so - well, the Atlantic anyway. So, I've interpreted my life differently to others and my memories aren't super faithful captures of reality. They are more of an artists impression of stills from the life of me. So, these faulty impressions are what keep me seeing my life as a joined up journey from birth to death. It's not having the same body (as I'm replacing it, bit by bit, over the years of my life). It's certainly not reality. It's just a series of memories which create a complete, unbroken narrative.

Broken narrative

When I wake up in the morning and recall going to bed that night, there has been a definite break in the flow of the narrative. Your internal memories just stop, then start again 8 hours later. If, during your sleep you were cloned, I think most of us would naturally agree that the person who woke up next day in your bed would be you. The person that woke up in the cloning room wouldn't.

Who would the person waking up in the cloning room be? They would wake up in a strange room with all of your memories, right up to going to bed that night.

I think the answer becomes a little less obvious if you now imagine the Star Trek transporter. This device would disassemble people in one location and then reassemble them in another. Is the newly materialised person you? If the answer is yes, then the only reason it can really be you is if the definition of you is your memories.

Now me

It is easy to imagine seeing an unbroken narrative in action when you are at work interacting with a colleague and one moment has to follow another in a sensible order. Even though time has past it's easy to believe that "start of the conversation" you is the same person as "end of the conversation" you. But she isn't, "start of the conversation" you is dead, consigned to the foot notes of history. You can't go back to her and get her to change the course of the conversation.

If we follow this logic, every attempt we make to define "now me" becomes, in the very moment of cognition, "past me". "Now me" seems to exist in an almost impossibly thin fragment of time, by the time we have recognised that something is happening to "now me" it's a memory.

Future me

This is thus the only guy who can really be relied on to get anything done. So he's also the guy we have to protect and care for. Imagine you are told you will be given £20 and a punch in the face. If you could assign each of those to a particular you, I'm guessing most people would assign punch to past you and the money to present you for future you to make use of? How much strain "now you" will take on to make things easier for "future you" seems to vary greatly. I find it quite an interesting concept and way to think about reality. To the point where I think in this manner. If I am performing some particularly onerous task for future me, I hope he'll appreciate it, or if I'm being lazy, I'll think "Ha! Screw you Monday morning Ant I'm leaving it to you to fill the car with petrol".

Who am I?

Well, past me is clearly a lie - me as seen though a glass darkly. Present me is too fleeting, gone before I ever get to know him. Which just leaves future me, who doesn't even exist yet and he's only a figment of my imagination! Each of my memories is just a frozen instant in time like a single frame in a movie. Just like a character in a movie, I am the summation of all of those snapshots played at 25 frames per second to create a coherent narrative. I am that narrative...



Good enough

I was reading a blog post by one of my favourite authors talking about how difficult he finds it to hand in a manuscript.

"It’s a hard thing for me, letting go of a manuscript. Other authors are very matter of fact about it. But for me, obsessive word tinker than I am, I hate knowing that after a certain point I won’t be able to go in and fix things any more."

I feel something very similar when I'm coming to the end of a milestone and the code I've been working on is getting close to "complete". Because I am paid to create functionality and not art, it's actually possible for me to over polish the code. So I thought I would write about what goes through my head when I'm trying to decide if my code is ok. Obviously, the code has to meet the written requirements - otherwise it is deemed "not good enough" by QA.

Meeting the written requirements

  • Obviously, the software I write has to meet the immediate functional requirements - it has to work as intended.
  • It, usually, also has to meet the design requirements - it has to look right.
  • There are also user experience requirements - it has to feel right.

However, the written requirements tend to deal with the tangible parts of the software. It now becomes a judgement call on the part of the developer whether the code she has written meets the required standards for the unwritten requirements - things like maintainability, readability, reusability, extensibility, architecture and test quality. How important these requirements are depend very much on what you are building and the time frame your are working in.

I genuinely believe there is more value in a developer who develops good quality software quickly, than code poetry slowly. I justify this by saying that after a certain level of quality in a piece of software the effort starts to out weigh the gain and the reason for putting the effort in becomes less about the software and more about developer ego. I think the developer who understands this and judges correctly when to stop is the better craftsman.

Meeting the unwritten requirements

Software is constantly evolving and it's sometimes not possible to come up with the "best" solution for a piece of code until after it's been in use for a while. We were seeing lots of forking in the code where data needed to be processed differently depending on certain circumstances, so we decided to write a more elegant method of dealing with this. I closed the code review in which the final outcome of the discussion was to leave the code unfinished and revisit it to see how it's actually being used. The more time that has past, the more I think that turned out to be a really good idea. We waited to see how other developers would need to use it and how some might try and abuse it. The solution we have now makes the common forms of abuse much more difficult, while aiding the current common usages.

The above is, in my opinion, an example of where good quality code really shines. The code doesn't just perform it's own task, it creates a process for other developers to quickly perform similar tasks. When given a new task, most developers will look at the system and see if something similar has been done before. At some point, your code will likely be used as a base for something similar, or a small part of it will be used as the pattern for "doing x" in the system. You can aid in this by making the code easy to read and understand. If it's loosely coupled, it'll be easier for other devs to work into something new and that new thing will likewise be loosely coupled.

I am a big fan of using tests to help other developers understand the subtlety of the requirements of my code. If I make an assumption during the development of some code and it turns out to be wrong, that's a test right there. If a future dev makes the same assumption and introduces a bug because my tests didn't fail - that bug is on me.

When trying to decide if my code is "good enough" yet, here's what usually goes through my head:

  • Would I be ok seeing this code replicated through the system.
  • Is this problem local to this code, or do I need a global solution for other devs to use.
  • Is this problem properly tested.
  • Can I justify changing this?

Thursday, 29 May 2014

Arguing with stupid people

Changing your mind in response to an overwhelming argument is as fine a quality as it is a rare one. I was reminded of this fact yesterday in discussion with the current Mrs Ant. Then, again, today when a friend posted a Mark Twain quote I like and I thought it might make an interesting blog post.

"Never argue with stupid people, they will drag you down to their level and then beat you with experience."

Mental models

We all have a mental model of the world in our brain, our version of the world, our place in it (the centre) and our friends and acquaintances as satellites orbiting us. This model is super useful for us, as it allows us to play out scenarios in our heads before trying them out in the real world. For example, I am in a room with my boss and his boss. My boss makes a suggestion which I think is stupid, rather than blurting out that fact and suffering the consequences I can run a series of scenarios in my head, before commenting.

  1. Hey Bob, 1963 called, they want their shit idea back, oh and November the 22nd says it wishes it was you instead of Kennedy.
  2. Yea, nice one, or we could do x, might be quicker?

Now we run the simulations and go through the likely outcomes.

  1. Bob loves a good roasting and respects opinionated people. Bob's boss looks like a hard businessman, just the type to take the hard line.
  2. It's a pleasing answer, but it puts across two points, which makes me come across as uncertain.

It may seem unnecessary to state that this exchange all goes on inside my head. That the Bob referred to here is my mental model of Bob, and may, in fact, not represent the real Bob in every aspect. Yet the world is a complex place and we are often surprised when an interaction goes completely differently to the simulation. Unfortunately, we don't think very much about how poor a representation of the real world our mental model is. This is largely because we need to have faith in our simulations in order to act without undue hesitation.

Changing the model

Each time one of our simulations leads us ary, it causes us to restructure our mental model. This is fine for non weight bearing parts of the model, for example, realising you actually do like olives. For most people, there's not too much re-shifting of heavy mental furniture to accommodate this new fact. This shifting of mental furniture takes a great deal of mental effort.

If I can stretch the analogy further and imagine changing my mental model to switch my opinion of a co-worker to be like moving the sofa in my living room. As well as expending the energy to move the sofa, I have to adjust all of the things associated with it. My mental model must remain consistent, useful and operational in the same way my living room does. I can't just turn the sofa to face a wall and continue using it as is. I need to be able to see the t.v. and ensure I get enough light to read.

This effect is even greater when being asked to accommodate new information. This is why some of the most persuasive arguers will take the time to help you build the mental frame work into which they want you to place their new idea long before they ever get to the idea itself. In his excellent books Douglas Hofstadter takes us on wonderful walks through Godel's theorum, Escher's art and Derek Parfit's transporter thought experiment before he gets to the subject of conciousness. Those amazing Eureka! moments are where the last piece of the puzzle slots gracefully into your newly formed mental model of the world.

Mentally lazy

Obviously, some people are quite energetic mentally, to them, it's fun to listen to someone and say "Hey, you're right, if I knock a wall down here and add another window there I'll get so much more light in and have room for that chaise longue!" (some people have weird taste in thoughts). Others are not and laziness can cock a deaf ear to even the most simple idea. This is why you can be demonstrably correct and still not get someone to listen to you. This is why people get angry with you for being right sometimes, because accepting your right idea requires too much mental restructuring. Some beliefs are simply so entrenched (so foundational) as to be literally unchangeable.

Entrenched beliefs may not be as detrimental as they first sound - if my mental model is right most of the time, but you have shown me an obvious edge case where it is wrong, what is the cost / benefit of changing my entire model? Remember, all of our mental models are incomplete, their value is in how well they help us predict our future, not in how logically consistent they are. This is nicely illustrated by Philip K. Dick, who was a barking mad drug hound, yet, never the less, operated at the highest intellectual level - giving talks on reality at universities. This was because, despite believing we were still living in biblical times, 50 years after the death of Christ, his mental model made correct predictions.

When I was younger I read Richard Dawkins' The Selfish Gene and the other books in that series. They moved my mental furniture through reasoned argument and I was a big Dawkins fan for nearly 30 years. I now see him arguing from a position of complete entrenchment as a die hard atheist / materialist against equally entrenched religious people in what are supposed to be serious debates. I know he can't possibly expect to change his opponents views (my internal model refuses to shift to allow me to see him as a fool) which leaves me thinking that he supposes I am a sufficient fool to be influenced by this sham. Sigh...

People's mental models of the world are important to them and serve as the foundation of who they see themselves as. The key to being successful in changing their opinion is to help them see the benefit of shifting to your model rather than proving theirs is wrong. I guess it also makes you a nicer person to understand when being right doesn't really matter.