We live in an attention economy. Unfortunately this sometimes (or should I say often?) leads to poor programming practices. Not your or mine poor practices but from all the others ofcourse. Consider the following example as stated in the Wikipedia article Principle of least surprise:
“A user is about to enter his username and password for a program or website when he receives an instant message. Some instant messaging clients will immediately grab the keyboard focus and move it into their own response field, because they assume the user will want to respond to the new message immediately. In reality, the user may be astonished to find that they have just typed their password into their IM client and sent it to their friends. This conflict arises because the two programs are not aware of each other’s existence, and cannot easily determine when they might get in each other’s way.”
So we see here that it’s the client that steals the focus. Look at the picture below to see how annoying it is if something gets focus without “approval”. The client ‘grabs’ the focus (which can be considered an act of theft!) and moves the focus to it’s own response field (which can be considered an act of greed or egoism!). Who’s to blame for this? The O/S architect? The programmer? The developer? The programming schools or institutes or practices? Or the “end-user” that didn”t make clear to the programmer that he shouldn’t steal the focus? I don’t know. Maybe it’s because we think that writing poor software is normal and should therefore be accepted. It’s a culture thing. Leading to mediocre quality software products. It’s a pity. I wish all of us a culture where we consider quality important enough to invest in. So we get better products.