Subscribe to tlhIn`toq's Blog        RSS Feed
-----

Programs do what you tell them to do, not what you wish they did. (Interpreting the client's instructions)

Icon Leave Comment
Its all about how you write your logic code. For example, doing what my wife said recently got me in trouble because I think like a programmer:

Wife: Honey, please go to the market and buy 1 carton of milk. If they have eggs, bring 6.

I came home with 6 cartons of milk.

Wife: Why on Earth did you buy 6 cartons of milk?

Me: Because they had eggs.


Your program will do the same thing. It won't do what you wish it to do. It will not infer some deeper meaning to the subtext of your code. It will do exactly what you tell it to do, exactly the way you told it.

For the people wearing helmets, but aren't on any of the sports teams let me explain how the client's (wife's) job spec was misinterpreted:

int quantity = StoreHasEggs ? 6 : 1 ; // True then 6, false then 1
BuyMilk(quantity);


Rather than

BuyMilk(1);
if (StoreHasEggs) BuyEggs(6);

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

September 2014

S M T W T F S
 123456
78910111213
1415 16 17181920
21222324252627
282930    

Recent Entries

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Categories