Describe your bugs

I took this while I was testing the olympus. Still works very well.

Found a bug today in the code that manages the “friendly names” of Connected Little Boxes. I let the user add a friendly name to a device so they can call it “Downstairs light” rather than “CLB-12d7ef”. I’ve added handling for the situation where they try to add a device with the same name as an existing one (I used the same method as Windows file explorer). If you try to use an existing file it adds a number on the end. The second version of “fred” is called “fred(1)”.My technique with bugs is to write a nice long description of what happens and how to fix it. I find that this gives my brain a bit of time to catch up and think it through. This is my description of the error and how I fixed it.

When you save the edits for an existing device it creates a new friendly name for it because it discovers that the old friendly name already exists – which of course it does. The current behaviour works fine for adding a new device (a new name is what you want), but breaks updating an existing device.  

Fixed it by passing the original friendly name back to the device edit Post handler. This can then check if the friendly name has been edited and add generation information if it has. If you try to make a name with your own generation, for example create a name called “fred(1)” where “fred(1)” already exists the program will make a new name of “fred(1)(1)” which is acceptable. If you want to get “fred(n)” where n is the next available fred generation you just leave off the number and brackets. I pondered whether to remove the generation value from a clashing name so that it would automatically pick the next number in the sequence, but this could result in confusing number changes where someone saves “fred(6)” and ends up with “fred(10”.

If you are faced with an error I strongly suggest that you do something like this and then add it to your daily journal so that you can go back and refer to it. If you don’t keep a daily journal I strongly suggest that you start one.