среда, 26 сентября 2012 г.

Don't Do Stupid Things When Trying to Help Protect the Environment

Everyone is trying so hard to help the environment. Energy saving there, recycling here. Soooo green...

...and sometimes so stupid. Look at Nokia chargers initiative. Newer chargers will consume less than 30 milliwatts in standby mode which is excellent. And each time a phone finishes charging there's a message saying that charging is complete and you'd better unplug the charger to help protect environment.

This message is brought up as a very clever step that makes every Nokia phone user responsible for the green future....

Well, no. The message about charging completion was always there, just the part about the environment was added at some point.

There's something weird in here, isn't it? It's Nokia charger consuming power in standby but the user has to make extra effort. Why?

The real reason is that those chargers are damn efficient already. Making them more efficient would require better electronic components that are more expensive and that would drive the chargers price up and guess who would have to pay for that? No, people don't like to pay more for greener chargers.

So the pseudosolution is to change the "charging complete" message to contain the word "environment" in it. Does nothing, still puts extra burden on the user but now allows him feel better because of "doing something green". Plus Nokia can now run a PR company full of impressive numbers on energy saving and reducing the environmental effect.


Yes, impressive numbers. To actually estimate anything you have to run the numbers.

Numbers don't lie.

Suppose we have a Nokia charger in standby plugged in for a full year and consuming 30 milliwatts. Just the worst case waste scenario.

Every day the charger will consume 0,03 watts by 86400 seconds (number of seconds in a day) which totals 2592 joules.

Now when you multiply that by the number of days in a year and then by the estimated number of chargers out there the result is very impressive.

Except that the number alone is meaningless. You have to compare it with something and see if it makes any sense.

Let's pretend that each day you will take the stairs instead of using an elevator. Let's assume your weight is 60 kilograms and you go three meters up. This makes you spend at least 3 meters by 60 kilograms by 9,8 meters per second 2 (gravitational acceleration) which totals 1764 joules.

You see, the elevator will not need to use that energy because you took the stairs.

Climb up two floors up and you totally offset the energy saving of the unplugged charger. Plus now you've got some physical exercise and you have better chances of not needing a heart surgery and a ton of drugs which are not that environmentally friendly.

Which will you choose – to do something stupid and protect the environment or to do something useful and protect the environment?

четверг, 13 сентября 2012 г.

Safety Device Useless Because of Poorly Worded Manual

Teh battery terminal covers... Tiny pieces of plastic that could prevent shorting the mobile device battery when the battery is being stored or transported much better than the stupid "don't store the battery in a pocket next to a paper clip" warning.

Now turns out there is one company that ships mobile devices with battery terminal covers. Let's look at Nikon Coolpix AW 100 camera manual. Confirming the Package Contents section clearly shows that the camera battery is shipped with a terminal cover.

One small step for a company, a giant leap for mankind. Sort of.

The problem is that shipping the battery with the cover IS NOT FUKKEN ENOUGH because users are not familiar with what to do with that. Scary paperclip warnings have been there for ages, but users have never seen a terminal cover before. With such background they can only fear a paperclip, not do anything constructive with a terminal cover.

Camera Reference Manual to the rescue? Okay... section For Your Safety says observe the following precautions when handling the battery for use in this product and then there's a bullet list that among other stuff includes this:

[B1] Do not short or disassemble the battery or attempt to remove or break the battery insulation or casing.

Okay, then two bullets later (both completely unrelated to shorting the battery) it says this:

[B2] Replace the terminal cover when transporting the battery. Do not transport or store with metal objects such as necklaces or hairpins.

This is not how the manual should handle this. Here's what's wrong.

First of all, look at [B1] wording. You see, shorting the battery and disassembling the battery are listed as if they are similar actions. They are only similar because they are both Bad Idea™. Other than that they are very different. Disassembling the battery is usually a deliberate action but shorting the battery can be either deliberate or accidental (like accidentally connecting the terminals with a paper clip in a pocket).

These two things should be worded separately. Disassembling or otherwise hacking the battery with a pickaxe should be a separate bullet point.

Next, [B1] that mentions that shorting the battery is Bad Idea™ and [B2] mentioning the terminal cover and the metal objects are separated with two completely unrelated bullets.

This makes [B1] and [B2] unrelated in the reader's mind although they both talk about shorting the battery and how to avoid it.

Finally look at [B2] wording. This on its own deserves careful analysis.

It says the user should put the cover onto the battery while transporting it but doesn't mention battery storage although storing and transporting the battery are totally equivalent in terms of shorting and risks thereof.

Next, [B2] says the user should not transport or store the battery with metal objects. Why the F should he not?

Remember, there's a terminal cover that he should have put onto the battery and that cover should prevent shorting. When the cover is on it's okay to store the battery in a bag full of tiny metal objects – no shorting will happen.

Do you see what's going on? According to the manual the terminal cover is just needed but it doesn't protect against shorting the battery. According to the manual it's just useless or maybe protects from dirt.

So, Dear Nikon, you've implemented the terminal cover, you've produced and shipped it and then you wrote in your reference manual that the said cover is a useless piece of plastic that just needs to be there. Every box with Nikon Coolpix AW 100 now contains a terminal cover and a manual implicitly declaring that the cover is useless.

EPIC FAIL

Here's how you fix it.

1. Remove do not short wording from [B1]. Only leave the wording about disassembling and otherwise deliberately (most of time) messing with the battery in [B1].

2. Move do not short wording into [B2]. Shorting the battery (either deliberately or accidentally) is a separate problem and it should be addressed separately. The terminal cover is implemented to avoid accidentally shorting the battery when the battery is being stored or transported. Remove do not transport or store with metal objects wording, replace it with a phrase saying that a metal object (such as whatever examples you want) can accidentally make a connection between the uncovered terminals and short the battery and to avoid that the user should only store or transport the battery with the terminal cover on.

This makes the terminal cover ACTUALLY USEFUL and saves a billion of cute kittens.

четверг, 23 августа 2012 г.

How a Trivial Technical Problem Turns into a Major Hazard

These days portable devices are EVERYWHERE. Phones, computers, power tools have decent mileage on batteries these days.

EXCELLENT

Now mileage is not always decent ENOUGH and so you'll often want a spare battery or two. This applies to all kinds of devices the number one being Android and number two being power tools.

POWER TOOLS

Unlike other devices most professional power tools come with two batteries. You charge both, then you use one of them until it goes empty. The empty one goes to the charger, the second one goes to the tool. If you have to use the tool where there's nowhere to plug the charger – you may want to have more batteries with you.

Anyway at some moment there's a battery that is not connected to the tool and is likely not connected to the charger. It is on its own.

Have you heard that a battery has TERMINALS? You know, the metal thingies which connect the battery to the tool. Do you have an idea of what happens if there's a direct electrical contact between the terminals?

That's called a SHORT CIRCUIT. This is FUKKEN BAD for teh battery – it will spark, overheat, explode, hell will break loose. Search for "battery explosion" on YouTube for details.

Do companies who produce phones, laptops and tools know about that?

Sure they do. Let's open a manual for ... say... Bosch GDR 10,8 V-LI power impact wrench. Page 14 says this:

When battery pack is not in use, keep it away from other metal objects, like paper clips, coins, keys, nails, screws or other small metal objects, that can make a connection from one terminal to another. Shorting the battery terminals together may cause burns or a fire.

This is how companies typically "solve" the problem. A warning in the manual.

EXCELLENT ARE YOU KIDDING ME?

Suppose I'm packing tools into a bag. I want several screwdrivers, wrenches, pliers, a hammer, some wire and maybe some screws. And finally I want a power tool and a second battery pack for that tool.

You see, if I put the battery pack right into my bag there's risk that the wire or the screws or some combination thereof will get to the terminals of the battery pack and cause a short circuit.

Looks like I'm screwed.

Not really. There is a solution. It is wrapping the battery into plastic film. Most likely that will be a plastic bag.

Yes, a plastic bag. The tool costs several hundred bucks but you have to put its battery into a plastic bag because otherwise it can short circuit and then hell breaks loose.

EXCELLENT ARE YOU KIDDING ME?

Let's looks at it in details. Suppose you want to design a phone, a computer or a power tool. You will have requirements – maximum weight, maximum size, minimum performance, maximum heat dissipation, duration of runtime off the battery and many many others.

You see, these requirements are conflicting big time. If you want a bigger battery you get a bigger heavier device. If you want more power you'll have problems dissipating that power.

Now you spend months and years putting all that together – you choose all the right components and pack them the right way so that your device is powerful enough and small enough and lightweight enough and lasts on one charge enough.

You're so FUKKEN PROUD of yourself. You hire a ton of marketing specialists who market ur device everywhere talking about its sleek design and its amazing power and lots of irrelevant crap like number of screen colors of a phone and voltage of a power tool, but...

... your user buys your device for several hundred dollars and has to pack the second battery into a plastic bag to avoid a short circuit ...

... and all you can do is put a warning into the manual listing all kind of metal and other conductive crap that can cause the short circuit?

EXCELLENT ARE YOU KIDDING ME?

Here's what to do. Next time you design a battery design a protective cover for the terminals.

If you design a power tool – that's very easy. The battery typically connects to the tool handle. Clone the part of the handle the battery connects to, then cut off all the extra plastic which forms the tool body, form the rest into a plastic cap. You've got a plastic cap that fits to the battery in the most secure way possible and protects the terminal against short circuit.

If you design some other kind of device at least provide a tiny plastic box.

Never ship second batteries without a protective cover. Make protective covers available through your service centers in case your users lose covers – sell them dirt cheap.


Now go to your device manual and change the warning to say "dude, hell breaks loose if there's a direct contact between the terminals, to avoid this put the protective cover onto the battery when the battery is not connected to the device or the charger".

THIS IS SO FUKKEN EASY and IT MAKES A REAL DIFFERENCE

Bonus points – you have less lawsuits, easier public relations and maybe you can save a bit on marketing your device. Less risk of short circuit sounds FUKKEN GOOD...

It's a SAFER DEVICE and everyone likes safer devices.

понедельник, 13 августа 2012 г.

Your Order is One Upselling, Do You Want Hatred With That?

If you google for upselling you get more than 6 million hits. It's so popular.

The whole idea is the following. Your business is selling some premium crap and to maximize ur revenues you want to sell tons of that premium crap. One of the techniques is upselling.

You wait till ur customer decides to buy something and then offer him something extra... or a bigger version of what he want to buy... or both. Like the classic McDonalds "do you want fries with that?".

Now the upselling proponents say it increases revenue at almost no cost. The proponents explain it this way...

...some unfortunate dude at McDonalds has already made his mind to get this and that...

...and they're already in front of the counter spelling their order out...

...it takes almost no effort for a clerk to ask "do you want fries with that"?

Like if the dude is an imbecile and kind of forgot to order fries he will spend extra but if he doesn't want fries there's nothing to lose here.

Kind of a no-brainer. Just ask everyone "do you want X with that?" That's easy, isn't it?

Now dear upselling proponents...

STOP RIGHT HERE AND THINK

This is just annoying. ANNOYING. Go find an online dictionary and look this word up.

Ur customer wanted a coffee. "Do you want ice-cream with that?" No, F off!!!

Ur customer has already ordered more than a person can eat per day. "Do you want fries with that?" No, F off!!!

Ur customer orders a single cheeseburger. "Do you want cola with that?" No, F it, ur customer is not that stupid to not know better if he wanted cola when he came to the counter.

Do you really think that a person will go to the counter to order a single cheeseburger and not order cola if he really wants one? Really? Is he that stupid?

Yes, sometimes upselling may be a good idea, but don't just try to upsell anything to anyone.

Otherwise it's ANNOYING and now that you've looked up this word there's one more for you -

...that second word is HATRED. When you do something ANNOYING over and over again that triggers HATRED...

...and that's not some generic untargeted HATRED, but HATRED towards ur business.

Do you want customers to experience HATRED towards ur business? Do you want to spend a fortune on advertising and then trigger HATRED by clueless use of upselling?

The proponents of upselling measure the revenues and then conclude that using "do you want X with that" upselling leads to some percents of revenues increase.

Excellent.

Now did they measure the extra time people have to wait in the line behind the dude who is being upsold to?

It's that easy. You're the fourth in line at McDonalds. The dude at the counter orders a single cheeseburger and the clerk tries to upsell a cola to him, the dude refuses. You have to wait extra five seconds in the F***ng line. Now the next in line dude comes to the counter and the clerk tries to upsell to him. And then the next dude. And then it's ur turn to waste time on upselling.

How do you feel about that? You've just wasted 20 seconds on upselling. Excellent investment. Come tomorrow for more.

Did the upselling proponents measure this waste of time and HATRED it induces?

Do you still think upselling has almost no cost? Do you want upselling with that?

пятница, 27 июля 2012 г.

Raspberry Pi is NOT a credit card sized computer

Raspberry Pi... A small rather cheap and rather powerful computer. No problems with that.

What about marketing?

You see, it is marketed as being a credit card sized computer. Well, let's see...

A credit card size is 85.60 × 53.98 mm and Raspberry Pi size is... 85.60 × 53.98 mm

EXCELLENT!!!

Yet a credit card is 0.76 millimeters thick (there's an international standard for that) but Raspberry Pi is 17 millimeters thick.

Now grab a calculator and ensure that 17 millimeters is something like 22,37 times more than credit card permitted thickness. This kind of means that you need at least 22 credit cards to occupy the volume Raspberry Pi occupies (and to make any credit counselor seriously worried).

Don't believe that? Okay, follow this plan: get Raspberry Pi, get to the nearest ATM and try to insert Raspberry Pi into ATM card slot.

IT WON'T FIT IN THERE

It's not credit card sized, it's size of a cigarettes pack, but that's not so good for marketing.

This also explains why "electric imp" module being packed into an SD card is so cool. Although you likely won't really need to use it in the form of an SD card you can be damn sure that it fits into SD card dimensions and you don't need 7,98 times more height than an SD card would occupy.

понедельник, 19 марта 2012 г.

Static Analysis is Not to be Offered Through Fear

Recently I was wasting time watching stuff on YouTube and at some moment I thought that static analysis tool vendors might have some marketing materials there.

Turns out, they do. Here's a neat "BUY IT OR UR SCREWED" video from Coverity dudes:

WOW! SCARY!

The irony is I'm rather old and I have very good memory. I watched the above video and I got sure I've seen something like that before.

But where?

Who might use these "use it or ur screwed" tactics so persistently that it got imprinted in my brain and I now remember it?

Here they are: the toilet cleaning chemicals.


WOW UR TOILET IS FULL OF GERMS USE OUR CHEMICAL OR UR SCREWED

What can I say?

Dear Coverity dudes! It's gonna be okay, just don't lick ur toilet.

понедельник, 27 февраля 2012 г.

How to Not Present Static Analysis Results

Aside of sad fact that it's impossible to try Coverity without first getting the Seal Of Coverity Sales Force Approval the next big difference between Coverity and PVS-Studio anyone can see is...

TEH MARKETING MATERIALS

How This Could be Done

Let's look at a typical PVS-Studio scan report. This one happened to get right in my way and so I link to it here.

A misprint... Yes, I see. Risk of array overrun... I see. Several more subtle defects.. I see. No freaking idea how those defects affect the program functioning, but they are presented quite well and are easily assessible by anyone who is willing to pay attention to them.

One might wonder how the program could run with those horrible defects.

This is quite simple. Defects that actually manifest themselves have been identified earlier using other methods – plain old debugging, unit tests, peer review, whatever else. All the rest requires some effort to get exposed. That might be some unusual dataset. That might be some unusual sequence of user actions. That might be some unusual error indication. That can be upgrading a compiler or a C++ runtime.

Defects are defects. You can't lie to the compiler they say, but not all defects are created equal. Those subtle things will sit in the codebase for years and then all of a sudden someone runs PVS-Studio on the codebase and WOW WHAT A HANDFUL OF HORRIBBLE BUGS ZOMG ELEVENELEVEN!!! they will think.

So a scan report alone is worth nothing – it still takes a developer who is familiar with the codebase to assess and possibly address each reported defect. PVS-Studio scan report does exactly the right thing – it presents defects one by one together with some analysis, nothing more.

How This Should Not Be Done

Now look at Coverity marketing materials. You will have a very hard time to find a scan report like the one linked to above with Coverity scan results. Yet once in a while Coverity dudes will issue an Integrity Report.

An Integrity Report is a very enthusiastic document containing such words as mission, seamlessly and focused on innovation. Not bad as a starter – at least presence of those keywords identifies clearly that there's too much marketing in the first three pages.

Moving on to Table A... Oh, this table shows a distribution of project sizes. Using the word distribution somehow implies that the data gathered has some statistical significance and so deserves extra trust. Well, with 45 projects total trying to build a chart and call it a distribution is very silly. You see, they had TWO projects with more that 7 million lines of code. That's unbelievable, I'm breathless.

All the rest of the Report is also full of similar completely meaningless tables. Yes, it is cool you found 9,7654 defects per square foot of some project. But until you let me try your program – I don't care, those figures don't matter any more than a 132 percent efficiency claim (the post is five years old, yet still relevant).

Fast forward to Appendix A. Tables 2 and 3 summarize defects but assigning each a category and and impact. Let's see...

Control flow issues. What's that? Is it when I forget to put a "break;" at the end of a "case" in a "switch" statement? So you say it has medium impact... Okay. What about "main()" returning immediately? That's a control flow issue as well and don't tell me it has medium impact. Not all control flow issues are created equal.

Null pointer dereferences have medium impact, don't they? Sure, my code defererences null pointers here and there and each time that happens users get a candy. Perhaps the Report authors meant potential null pointer dereferences which is a situation where code dereferences a pointer without first checking that it is not null. Good news is checking a pointer each time before it is dereferenced clutters code big time. Again, not all null pointer dereferences are created equal.

Error handling issues have medium impact. What is that? Is that checking for error codes of Win32 API functions? Sure, any time a program wants to open a file without validating whether the attempt to do so failed and just proceeds reading it's almost no big deal for the user. No access to the folder? We'll pretend we've saved the file. Whatever. Not all error handling issues are created equal.

Integer handling issues have medium impact. Sure, overflowing an integer while computing a memory allocation size is no big deal. Just allocate whatever amount it happens to be and pretend it's the right size. Not all integer handling issues are created equal.

Insecure data handling has medium impact. What's that? No freaking idea, but I something tells me not all cases of insecure data handling are created equal.

Incorrect expression – medium impact. Sure, misplace braces wherever you want, no big deal.

Concurrent access violations – medium impact. You just spend the rest of your life debugging them, no big deal.

API usage errors – medium impact. Your code erroneously forgets to specify the path and that causes entire contents of Windows\System32 be deleted. No big deal.

Program hangs – medium impact. The program hangs only when being run on a computer outside a Windows NT domain. You run it just fine inside your corporate network, then go to a trade show and it stops working, your laptop turns into a thousand dollar space heater with a screen. No big deal.

Why is no category assigned low impact I wonder? Is it because authors didn't dare call a software defect having low impact just because of belonging to some category?

This doesn't work. You can't throw several thousand defects into several categories and then assign each category an impact level. This is just impossible. If you're a software developer you must realise that beyond the shadow of a doubt, otherwise just quit your job immediately and go to the nearest McDonalds outlet – they have a "help needed" sign waiting for you.

The whole Integrity Report is just a big mess of numbers and diagrams. It's usability is not even zero – it is negative. The report scares the hell out of anyone who is concerned about software quality and stops there.

The Outcome

So what's the difference between PVS-Studio marketing materials and Coverity marketing materials? The former present facts that one can interpret and verify. The latter just try to scare by summarizing and no chances for verification.

Because not everyone deserves a free Coverity trial.