Thursday, September 20, 2007

I smells somethin'

Programmer 1: “What the... That code is horrible. Who did that?”

Programmer 2: “Erm... Yeah that was me. I know it's crap.”

Programmer 1: “Crap? This code gives crap a bad name. This code goes right by crap and out the other...”

Programmer 2: “Yeah, yeah okay, that'll do, I know, but I wrote that shit like 3 years ago.”

Programmer 1: “Uhuh. Umm... This code over here is just as bad... You wrote this shit yesterday!”

Everyone knows that the worst code you have ever seen is the code that you wrote 6 months ago. However you are supposed to learn from your mistakes*.

* That way you get to make new and interesting ones each time.

Wednesday, September 19, 2007

So don't press that button!

It was (probably) Murphy who said (something like) if there are two ways to do something and one of them with have disastrous consequences, the probability that someone will do it that way is 1. Thus, all good programmers ensure that pressing the wrong button at the wrong time will not cause things to blow up. Lumped in here are things like checking input, clicking in the wrong spot, pressing the delete key at the wrong moment. For these things and more we can ignore, correct or confirm inputs. Good. But you can't be pissed off when you click the wrong, but valid from the context, button and that functionality completes successfully.

For instance, there is functionality A and functionality B that both act on the current input. These functionalities are both executed thousands of times per day, there is no way to tell from context (previous operations) which one is more likely, and there is no time to have a confirmation. So when you have operators that click B when they mean A (and not notice - it is not like you can't cancel you B and put in an A) you have a training issue. There is nothing the system can do about it! That is not the worst of it though. What I really love is the service calls and bug requests saying that the reports for the operations on a certain terminal are “all screwed up, there are B's where there should not be.” So I take the 10 minutes that it takes to verify that there were no problems with the processing and what I find amounts to “That place where there was a B is because the operator pressed B.”

“Why is my transaction cancelled?” Because the operator cancelled it.

“Why did the upstairs bell ring?” Because the person pressed the top button.

“Why is there a charge of $0.01 on my credit card?” Uhh, because the cashier ran a transaction for 1 cent on your card?

Tuesday, July 31, 2007

ClickOnce - or: how to instafuck your whole installed base with one click of the mouse!

Fuck me that was fucked.

We are rolling out a new version of a program which is updated via ClickOnce. We currently (luckily) have about 12 of 80 machines installed - the rest are using the old, manually updated software. I am actually pretty glad that we had today's problem today and not in a couple of days time when the whole thing was rolled out - _that_ would have been a major shit fight.

This morning I got a request for changes. Nothing huge. Thought it would be a nice demonstration for the live update feature of the new system. 10 minutes to code. Took my time testing, 1 hour. Published the changes onto the beta site, let the test machines auto-update. Cool. I sign off on the mods, the client give the go-ahead for live. I publish on the live server. Sweet. Now I keep a test machine connected up to the live publication just so I can have a last minute test to make sure all is well. I go and run the client on that machine. The auto-update barfs. Crap. I go to look in the program group for the program. The machine freezes. Crap crap. I reboot and try again. No go. Now I am starting to get a little worried. I connect up to one of the client's live machines which is not being used at the moment and let the auto-update run. Barf. Crap crap crap. Machine freezes. Fuck. I try to uninstall the program, the item does not disappear from the control panel. I try again. Freeze. Reboot. Uninstall. Okay. Now I reinstall the new version, and it works. However the calls have started to come into the call centre... “We logged out and logged in again and it did its auto-update and now the computer is broken”. Fuuuck. So the technicians get to work some overtime uninstalling the broken update then reinstalling it from scratch, and I get to do some overtime to work out why the fuck it did not work.

After a 30 or so re-deployments in different configurations I find out that some kind soul has installed Windows Installer 3.1 on my testbed. I add it as a prerequisite so it gets installed first - now the auto-update works. So that is why my initial deployment test did not fail - there seems to be some kind of problem with the default version of Windows Installer, and I didn't see it because the testbed already was using a later version. I go check in with the technicians and we run a test on a machine that was not yet fucked up - installed Windows Installer 3.1, then let the auto-update run - no problemo. Fuck. I wanna break someone's fingers!

So after an hour of downtime for > 10% of the system I know what we have to do - re-do the install from scratch with Windows Installer 3.1 as a prerequisite. We have to start again because it has to be installed as Administrator. I am not going to be popular with the technicians...

I used to like ClickOnce. But now I am not so sure. It is very difficult to integrate into a responsible deployment strategy. When the whole system is deployed that way, how can you test a new update? I have never seen a case where the re-install (rather than the auto-update) does not work, so you can't just say that if the clean install works the auto-update will work. So imagine that all the machines are deployed from the live site - the auto-update is kind of all or nothing, you can't point a few machines at a different server to make sure the update works. I guess you could copy the live site to a test site, install from there, then update the test site and let an update go through. There is also no rollback. Once you let the update go, it's gone baby.

Just goes to show you - must have test machine that is identical to the live. Well, I'm off to padlock up the test machine... where did I put those thumbscrews?

Saturday, July 07, 2007

Wake up!

For a while now I have had an alarm clock that can wake you up to a CD. I used it a bit to wake up to music, but I had always thought that I could do better than that and create a playlist specifically for waking up. Mostly I had to have the volume up loud enough to ensure that I woke up eventually, meaning that it was too loud at the start, jarring me awake - which I wanted to avoid.

Some things that I have noted about waking up. Waking up to the beep beep alarm is not nice, but it is certain to make you leave the bed. Waking up to white noise it better, but it is possible to sleep through. Waking up to nice music is the best, but again sleeping through is a distinct possibility. When I am not super tired, I will generally wake up at the sound of the CD spinning up, or the light pop sound the amplifier makes when turning on.

So what I have thought might be nice is a kind of ramping up in the volume and wakeability of the noise. I was thinking something like: Low volume environmental sounds, white noise like, waves, wind. Most time I would wake up to this, perhaps drifting in and out of sleep, remembering dreams, getting ready to get up. Low volume relaxing music. This will make me up if I miss the first sounds, I may even get up now if I was fully awoken by the first phase. Medium volume energetic music. This signals the time to rise. Could be possible to sleep until now, if so this will wake me. Loud music that it is basically not possible to sleep through, techno, metal, something like that. The three remaining are the backup plan. I basically don't see getting to this point very often. Medium to loud white noise tones. Loud beeping. David calls in dead.

So what remains now is choice of musics. I am thinking one of the tracks from the glasshouse CD for the environmental sounds. Either one of the early movements from a Bach cannon and fugue or something from hallucinogen for the relaxing. Good wake up music... indy rock, thinking female vocal, rising crescendo... have to think about this one for the medium volume energetic. Loud music backup. So many choices... PWEI, Rage, anything a bit violent and raucous.

Should play with the audio levels on the MP3s that I create for this so that the volume ramps up nicely. May not even have to worry about the final stages, just put another loud sound on with the levels really tweaked in the MP3.

(Might also be interesting to make the playlist, then merge it all into one track so that I can do different ones with different music and use them on shuffle so I don't get sick of the same music every morning...)

Friday, July 06, 2007

Just do it

I feel like productivity people (the GTD crowd, that sleep guy, zenhabits) explaining how to lose bad habits, how to have a morning routine, how to organise your life is much the same as some happy person telling a depressed person to “just feel happy”.

I read somewhere today that when introducing a new habit into your lifestyle, “the first step is getting yourself to do it”. Fuck no buddy - the WHOLE THING is getting myself to do it. Do you not understand that what I have trouble getting myself to do is ‘getting myself to do things’?

Why so glum little girl? “I'm depressed”. Well cheer up, you'll feel much better if you just smile and be happy. Being happy is the first step on the road to not being depressed.

*Barf*

Friday, June 22, 2007

Not my problem (I wish)

It can suck sometimes to be left working on a project after the original project manager has left the company. All their mistakes and oversights become your property - even the ones that are invisible until the fan is at full speed and the excrement is in flight.

Customer: “We tried to use the system today with the PC disconnected from the network and it does not work.”

Me: “No I don't suppose that it would. It needs to connect via the network to its [hardware device] at all times.”

C: “Well what about each year when we sell things outside of the store with no network?”

Me: “I don't know.”

C: “Why didn't you think of this before?”

Me: (Because it's not my job? How the fuck should I know? Maybe you should ask the guy who is not here anymore. Maybe you should ask why we don't have a project manager at all?) “We will certainly have to look into that.”

C: “You realise we need this to work by [the day two days from now] don't you?”

Wednesday, June 20, 2007

Output filter!

A corollary to the input filtering rule:

Couch your demands in terms that will make your actual desires apparent to the person whose assistance you are soliciting, rather than explicitly telling them what to do.

Let them work with you to solve the problem. Explain what effects you would like to see rather than how they should act. Let them figure that out for themselves.

One, they are probably better qualified than you to judge what they really need to do - assuming that you are involving them because it is their area of expertise.

Two, people are more likely to want to do something if (they think) it was their own idea to do so. Rather than looking at your demand and defensively trying to avoid change, the impetus for the action comes from within and they will likely feel empowered in its performance.

A, B, C

What part of “it has to done in the order A then B then C” do you not understand?

First you do A. Then later you can do B. Finally, when A and B are done, you may do C.

“Okay so, I have not done A yet, but B is done. Can I just do A now then C?”

Nooo! You have to do A first, then B then C.

Input filtering

One important difference between working with a boss and working without one is how you think about what you are asked to do.

Normally when you get a demand from you boss it comes with an express or implied priority, you slip it into your schedule, do it, and report back. Sometimes you may have some say in modifying the priority, sometimes you may question the validity of the task, but mostly you just do it.

Working now without any direct boss, just vague priorities from on high, this sequence of “receive work unit”, “execute” is often counterproductive. I knew that some filtering would be required, but I did fully understand the extent to which one must think about what people are asking for, why they might think they want that, hence what they really want, weigh that with who they are, and decide what I should give them. People seldom take the time to explain why they want something, and often what they want is not the right thing.

I need to focus on getting them to explain the problem they are trying to solve rather than let them specify which actions they think I should take. From there I can understand what really needs to be done (perhaps nothing) and help them to understand how this new action actually solves their problem. Only then can we decide on who will do what and when.

It is the same as with any problem solving. It is important to start with the definition of the problem - particularly when you are asking the help or advice of someone else. It is important not to colour their thinking with your supposed framework for the solution.

Friday, June 01, 2007

Hungarian notation

This (useful) notation prefixes each variable with a label or tag indicating the kind of information that is being stored - what is its purpose.

KIND. Not type. Please, either go and read the original (Simonyi) specification of Hungarian or just don't use it.

Calling your variables bSomething or iNumber or lpszBlahBlah is worse than useless.

Monday, May 28, 2007

Creationism

The universe is complex.

Far too complex to have been produced by random processes from nothing.

It is just not possible for more-complex things to evolve from less-complex things.

There must have been a creator.

The complex universe was created by a creator.

[logical continuation...]

The creator must therefore have been more complex than the universe.

The creator is very complex.

Far, far too complex to have come from nothing...

...

Friday, May 25, 2007

ReSharper - Awesome, Expensive, Slow

ReSharper (R#) is great. The refactorings and code completions and cleanups and warnings are truly awesome. I now really want all the code that I work on to pass with few or no warnings. But I am going to have to uninstall it for two fairly mundane (i.e., should be easy to fix) reasons:

  1. It totally has screwed up all of the keyboard shortcuts. Even after flipping back to all VS 2005 shortcuts there are some things that don't work, and worse, there are many nice features of R# that are no longer available at the touch of a button.
  2. God damn it's slow! Not on a new file, or a small file. But on big old files that have lots (200 or more it seems) warnings. Each time you make an edit to the file it re-analyses it which takes a looong time. (7000 line file, 280 warnings, 15 seconds)

These should both be reasonably easy to fix:

  1. Don't frig with the shortcuts! Give me a list of functions for which you would like to add shortcuts and I will assign them. Maybe this is doable by the end user - I'm sure that I could eventually get my old studio shortcuts working again, but I am not paying US$250 for a tool only to spend hours repairing the damage it has done.
  2. Let me disable the automatic analysis of the current file. Maybe in that nice little coloured box at the top of the colour bar there that had a hand icon but does not seem to actually DO anything.

I have used R# for a couple of days now, and I love it! You have a convert people! But I CAN'T use it like it is.

Wednesday, May 23, 2007

Web 2.0 style guide

Orange! Light green! Dark blue! Light blue!

Very faint diagonal or way off-centre circular gradients.

Dark text on light same coloured background.

Dotted (light coloured) borders (and horizontal rules).

Shiny glass or gel (jelly!) looking buttons (that are not usually buttons) and text.

Text sitting on a shiny table and all manner of other (3d) surface effects.

Big bold headlines. Often multiple down or diagonally across the page.

Smaller (gray) body text with lots of white padding.

Many pointed stars.

Cute icons.

No underlined links.

Digg this, post on reddit, blog this, tag on del.icio.us, etc., etc., etc. buttons.

I'm not saying that any of this is good or bad, just what I have been noticing.

Implementing IExceptionHandler

When using the Enterprise Library Exception Handling Block, there are (at least) two things that you have to do to get your custom handler to work that I missed when I looked at the docs. Specify CustomHandlerData as the ConfigurationElementType for the handler class:

[ConfigurationElementType(typeof(CustomHandlerData))]
public class WatchdogHandler : IExceptionHandler {
...

Provide a constructor that takes a NameValueCollection:

public WatchdogHandler(NameValueCollection attributes) { }

Final note.

I have had weird problems with the Enterprise Library Configuration tool. When I first created the handler class it would not load the assembly in the tool. It said that no class that implemented IExceptionHandler could be found. When I fixed the problems with my class it still would not load. Frustrated, I created another handler class from scratch (no other classes in the assembly, no other bits of code lurking around to cause problems) and that one loaded. Then, magically, the other class loaded as well!? Perhaps it was after all the closing and re-opening of the tool that it started to work, but I am not convinced.

Thursday, May 17, 2007

Phrases which flip my “no-longer debateable” switch

For the bible tells me so.

If you have nothing to hide, what is the problem?

I'm not a racist but...

It's just a theory.

Others that just make my sigh and shake my head:

Anything that is described as having an infinite number of configurations or settings.

That [insert mechanical device here] totally breaks all the laws of physics.

Wednesday, May 02, 2007

Item: Ninjas, two score. Check.

Is there any problem that could not be solved by 40 Ninjas? Didn't think so.

Ninjas: not just for breakfast anymore.

Tuesday, May 01, 2007

No, that's not it, try again.

If there is only one valid entry for some field in an interface, why don't you just put it in for me?

I was using this form created by someone here today, it is a form for our overtime: “Please enter the date for last Saturday” Uh... okay. I guess that was the 22nd of April. 04 22 Bzzt! No sorry that is not the correct date. Please Enter the date for last Saturday. Oh yeah, it is the 21st. Bzzt, that date is too far in the past. Are you serious? The only date that I can enter is 28th April? Bingo.

Well bugger me. If you will only accept one value, and you know what that value is, why don't you just put that in there!? And why can't I enter a date from a past week? It is not an automated system, this gets sent to our HR department for manual human entry into another system. She asked me to resubmit my form from 2 weeks ago. Sheesh. I can see why you would want to make sure that someone selected a Saturday (the start of our billing week), but why force a single Saturday? The people in HR know what they are doing, I am not going to be able to slip in old forms just by putting in an old date, if they are not expecting them they are not going to process them.

If there is really no date selection, don't ask me to select one.

Friday, April 20, 2007

Make ‘em mandatory!

There is a town in the states called Kennesaw with what might be called the opposite of gun control laws. Each household is required to own and maintain a gun. Must be a real shoot-em-up town right? People gettin’ popped left and right? Check out the article.

When you think about it, the proposition “If we make guns illegal there will be less gun crime” is pretty nonsensical. I would suggest the simplified relation “Gun crime is proportional to the difference between the number of armed bad guys and the number of armed good guys”. From this it seems likely that decreasing the number of guns the bad guys have would be good, just as increasing the number of guns the good guys have should have a reducing effect on the level of gun crime. This subtraction however is problematic: it is difficult to actively reduce the number of bad guns. Installing gun control laws causes the good guys who have guns to turn them in and the bad guys to snigger. Arming the populace may well put guns in the hands of the bad guys, but I would argue that on balance more good guns are created than bad - criminals don't feel they need gun licences, don't register their guns, don't pay retail, don't install gun safes, don't enrol in official how to shoot safely courses. Gun control laws have the opposite to the intended effect.

If you make gun ownership criminal, only criminals will own guns.

Wednesday, April 18, 2007

Are you packing?

I would like to live in a world without guns. I would like to live in a world without violence of any sort. If people were never even verbally abusive to one another I would consider that we were on our way to the perfect society. If someone threatens your security with violence, I believe the first response should be to try to defuse the situation, to remove yourself and those dear to you from danger into safety. Only as a last resort would I consider meeting violence with violence. But to not take that last step. To turn the other cheek as it were - well I leave that to other folk. For me, if you threaten me and you leave me no other recourse than to violence, then violence you will get.

I am starting to believe that in some societies this necessarily extends to a willingness to counter gun violence with guns. I have often thought, and heard said by others, that the death toll in shooting rampages would be very much diminished[1] by some of the people involved (witnesses, victims) having guns (heroes). I think that is a very difficult argument to dismiss outright.

I recently watched a video by Penn & Teller on the bullshit that is gun control. Their argument is very America centric (citing constitutional amendments), but I think the arguments within translate nonetheless. Then yesterday there was the shooting at Virginia Tech. I wonder how far a lone gunman would progress into his spree if some significant portion of the populace were armed. I wonder how many criminals, who now find themselves in the wonderful position of being likely the only person with guns in a couple of minute radius, would reconsider all manner of crimes. Overnight there was also a shooting by a security guard of a man in Sydney. Two men approached him with a drawn gun, likely not expecting any resistance. He shot them and they fled. Criminals use guns to have a power advantage. By reducing the power of the populace (removing their guns) you let criminals easily tip the balance in their favour - carry a handgun. An armed populace (maybe as few as 2% carrying weapons) could greatly reduce a lone criminal's expectation of being ‘the most powerful’ in a certain situation merely by carrying a gun.

I am not saying that everyone should or needs to have a gun. But those considered stable enough, those who can show they can do so safely, those who wish to take on the responsibility of using a gun if the situation requires, why not?

Gun control folks are always carrying on about needing to ban guns. “If only we could remove all the guns we would be safe”. Well think about this: Virginia Tech was a gun free zone. For the 30 minutes or so between 9am and 9.30am there was only one person in the area who had a gun, and I think we all know now what he decided to do with it. I just wonder what may have happened if some of the teachers, the RA, the seniors, the janitors were armed. I wonder even what would have been different about that morning if the gunman had even the slightest doubts that perhaps he would meet with people in that place that were armed and prepared to defend themselves and others.

I don't think ideas that appear logically sound ought to be dismissed outright by ‘zero tolerance’ style arguments.

[1] There was a shooting at another school in Virginia, not so many years ago. Though there was a different outcome at the Appalachian School of Law. Two students at the scene were armed. They subdued the gunman after he took his first victims.

Friday, April 06, 2007

*Sniff*

You know how when sometimes you are just sitting there and you smell this smell and like, you smell it and you can't work out whether it's toast or dog shit... Yeah, I hate that.