Thursday, 26 May 2011

It's obvious - not

One of my pet hates is when people write code that is technically correct, but easily mis-understood.
I came across the following today that really grates me:

if (!(a <= 0 && a >= -2))
{ ...}

If you're great at boolean logic, then that's fine - but most people read it incorrectly and mis-interpret the meaning. It would be much more obvious to write it like this:

if (a < -2 || a > 0))
{ ...}

It says the same thing, but is easier to understand

Wednesday, 25 May 2011

iPhone's

Okay, so those that know me, I've been pretty much Windows through and through for many a year; well, finally last week I gave up on Windows mobile and turned to the iPhone.
So far, so good. The battery life seems slightly better than the LG phone I had and it is certainly more stable.
Had an interesting one today though, I wasn't getting any sound out of my iPhone. headphones worked fine, just the speakers weren't working.
Quick google around and it seemed like it was a relatively common problem requiring new hardware - didn't like the thought of that really. Then I remembered that I'd had my phone connected to my laptop when changing sounds settings on the laptop. Hmm, suddenly, I'm wondering if that is the cause.
So, I get home, connect the phone to the laptop and sync through iTunes. Then turn the sound back on on the laptop and sync again - hey presto, sound is now working on the phone.
So Apple, I think you need to think about how much information you sync between iTunes and the iPhone - this is certainly one setting I didn't expect to be synchronised (and unable to change on the phone!)