Thursday, July 09, 2009

Programming IQ test

While the test is purely for fun, I have to comment on my score, which is no better than 75%. I got my bragging rights, though :-)

Many of the questions I got right are just as unimportant than the ones I got wrong.

The worst offender for suckers like me who takes this nonsense very seriously, are:

Question 6: Your local supermarket is all sold out of energy drinks, Jolt Cola, and Mountain Dew. Which beverage will keep you going, packing the most caffeine and sugar into a 12-ounce can?

Correct Answer: Sunkist Orange Soda

Your Answer: Dr. Pepper

Sunkist Orange contains just as much caffeine as runner-up Dr. Pepper but surpasses it in sugar content.

I mean, are programmers only located in the North of America? I live in Norway, which may very well compare to living under a rock. It certainly looks that way on certain government decisions. But that’s a Law of Nature, I guess.

But I digress. WTF is Sunkist Orange Soda? And haven’t people heard of coffee? Need more caffeine? So up the dose! Need sugar? No you don’t, but anyway, what’s stopping us from adding as much sugar as the coffee mug can absorb?

I think I am proud of failing #6.

Then there is, and this is the stupidest, as it contains no correct answer. I failed this one on purpose, because I had to answer something:

Question 12: Which of the following is the best way to write reusable code that is easier to maintain?

Correct Answer: Insert comments throughout your source code files

Your Answer: Use more global variables

Documenting your code is the best way to ensure that another programmer can understand it. All the other choices are recipes for disaster.

People who know me professionally, know I am a test infected kind of guy. Along with Test Driven Development comes Merciless Refactoring, and that is the correct answer. That is, both of them. Code comments are one of the hardest thing to get right, simply because they have to address the code at an abstract level. That is the only way to write comments which will stand the test of time. Most comments simply repeats what the code does, not why. Our variable-, method-, and class-names should do that.

I opted to comment on #16, simply because I hate to be wrong:

Question 16: A client has asked you to write some basic accounting software in C. What data type is best for representing figures in dollars and cents?

Correct Answer: Integer

Your Answer: Double

Integers can be used to implement fixed-precision math. Floating-point numbers, whether single or double precision, aren't accurate enough to keep track of finances.

I flunked this one. Badly. However, the question itself is ill-phrased. The available answers only refer to the type “Integer”, while it should be a set of integers. This is my opinion, though. I can see how one integer can solve the problem: Just look at any financial number and pretend there is always two fractional digits, or four if one need this kind of precision. In financials, we do. Then we pretend that the first two, or four, digits always represents the cents. But then we have greatly reduced the highest value possible to address. Better hope we never have to address Zimbabvian dollars with that software package.

No, the correct answer must be some composite of multiple integers: One for the cents, and one or more for the dollars.

Would I be a better programmer if I knew Kernighan’s best known achievement? Maybe. Or maybe not:

Question 17: For what achievement is Brian Kernighan best known?

Correct Answer: He was co-creator of AWK, a programming language for text processing

Your Answer: He was co-creator of the C programming language

Kernighan is known as the "K" in the K&R C language specification, but he didn't create the language; he just helped Dennis Ritchie document it.

In the same category: I didn’t know what “Turing complete” meant until #18. Who cares? And I don’t know about standard SQL, does that even exist as an implementation? All I know, is that loops are possible in T-SQL. And for PostScript? I thought that was a markup language, like HTML and XML:

Question 18: A programming language is said to be "Turing complete" if it can be used to implement any conceivable algorithm. Which is NOT a Turing-complete language in its standard form?

Correct Answer: SQL

Your Answer: PostScript

Standard SQL can't do loops, although you can get Turing completeness with proprietary extensions to the language from certain vendors.

That said, the questions I got right, by pure chance or otherwise, there are a few that doesn’t tell anything about programming skills:

  • Question 1: What is the relationship between Java and JavaScript?
  • Question 2: Hungarian Notation is a variable-naming convention used by some programmers. How did it get its name?
  • Question 3: Just-in-time (JIT) compilation improves the performance of languages that compile into bytecode. Which language featured the first JIT compiler?
  • Question 4: If I told you a key characteristic of my programming language of choice was that it generated threaded code, which language would I most likely be talking about?
  • Question 5: Once very popular and widely used, Pascal spawned a number of derivative languages. Which is NOT a successor to Pascal?
  • Question 7: What is the best way to preserve type safety in assembly language?
  • Question 8: Which of the following is NOT a central tenet of extreme programming?
  • Question 9: Why are race conditions a problem in modern software development?
  • Question 10: Why do some consider Ruby to be more "purely" object-oriented than other, more popular OOP languages such as Java and C++?
  • Question 15: Is P equal to NP?
  • Question 19: Which group has had the most impact on modern object-oriented programming practices?
  • Question 20: Which of the following is NOT a data structure used in modern programming practice?

There must be something wrong with me: Out of 20 questions, these are the only three I find useful:

  • Question 11: Failure to validate user input is one of the most common sources of software security vulnerabilities. When is it safe to accept user input without validation?
  • Question 13: Of the following, who is NOT the inventor of a programming language in current use?
  • Question 14: To what concept does "the mythical man-month" refer?

Take the test at InfoWorld.

Friday, June 26, 2009

Sad story

The posts on The Daily WTF are overall funny, except for this one, Death by Delete.

Sad.

Monday, June 22, 2009

Microsoft Office Live Nag Screen

It’s so nice that this screen never goes away.

Wednesday, June 10, 2009

ASPNET.MVC Goodies

First of all, the free eBook tutorial. This chapter alone is reason good enough to buy the whole book:

The best practices are already materializing:

Something to simplify the validation code:

Finally, enjoy a simpler MVC experience with:

Update.

Code Camp Server is a very real project done well. And open source:

Thursday, May 21, 2009

User story maps and use cases

I am three days old in my new position at my new employer, Osiris Data, and one of many exciting things that happens here are the always ongoing discussions on how we do things around here.

This time, I asked Terje on what they expect from design and inception, and we quickly went into a friendly debate on Use Cases in general and how to write them.

Two tings I came to remember during the conversation seemed to struck a chord:

  1. The new user story backlog is a map.
  2. Why I still use use cases.

Jeff Patton explains why we need a user story map:

Arranging user stories in the order you'll build them doesn't help me explain to others what the system does. Try handing your user story backlog to your stakeholders or users when they ask you the question "what does the system you're building do?"

And Alistair Cockburn writes about why he still use use cases:

I’ve been testing this out for the last 3 years – I walk in and ask, “On your agile project(s), do you by any chance suffer from any of these three things?” ... and then list the three … Much stronger than even I expect, there hasn’t been a single organization I asked these of that hasn’t said, “Oh, Yes, and How!”

And those three things he refers to are:

  1. User stories and backlog items don’t give the designers a context to work from – when is the user doing this, and what is the context of their operation, what is their larger goal at this moment?
  2. User stories and backlog items don’t give the project team any sense of “completeness” – what I keep finding is that the development team bids/estimates the projects at (e.g.) 270 story points, and then as soon as they start working, that number keeps increasing, seemingly without bound. The developers are depressed and the sponsors are equally depressed by this. How big is this project, really?
  3. Related to completeness, user stories and backlog items don’t provide a good-enough mechanism for looking ahead at the difficulty of upcoming work (In principle they could, just in practice they don’t) – I keep hearing this complaint, “We asked our customer (product owner) a question and she/he took 2 weeks to get us an answer. We must have the wrong person in this role.” No, they don’t have the wrong person, they have a broken process – certain types of questions take a long time to research, as the various departments and user groups work out what is the correct, balanced answer for the whole lot of them. Staring at the set of extension conditions in a use case lets the analysts suss out which ones will be easy and which will be difficult, and to stage their research accordingly. User stories and backlog items are not set out in that granularity early enough on for that assessment – the extension conditions are usually detected mid-sprint, when it is too late.

Friday, May 15, 2009

Will IT show it’s foolishness next?

In Too much experience could be hurting your IT job search, it’s argued that experienced IT professionals will get a harder time getting a new job. A CEO is quoted:

As a result many companies are focused on hiring front-line workers who can make the most impact on their business with the least amount of financial risk.

One commenter nailed it:

Inexperienced staff are always the riskiest to hire. I'm sure this can't be only obvious to me.

No it’s not. This is common sense, but as Voltaire once said:

Common sense isn’t very common.

We are, unfortunately, managed by too many people living in a cost-oriented world, where they equate cost to be equal to risk.  Eli Goldratt published The Goal in 1984. 35 years has past since then, and we have learned nothing.

Monday, May 11, 2009

Essential Firefox add-ons

Firebug to debug javascript and copy-paste the designer’s precious html code.

QuickProxy provide a single-click button on the statusbar to quickly switch proxy on and off.

Tab To Window and Tabs Open Relative because I like the way Google Chrome handle tabs. I dislike how Chrome does not support Firebug-like features. I could install Firebug Lite, though.