Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

A common expression you hear is "If all you have is a hammer, everything looks like a nail". It appears on Wikipedia as the law of the instrument.

It also manifests in IT, with developers, that, once they learned something, they use it... everywhere.

But how to truly avoid this if all you know of is a hammer at some point ?

share|improve this question

marked as duplicate by MichaelT, Giorgio, GlenH7, gnat, Kilian Foth Apr 28 '13 at 11:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Learn how to use a screwdriver? –  Tim Post Nov 24 '10 at 9:13
@tim: but suppose, i only know of the hammer. is screwdriver a tool ? does it exists yet ? how long to learn to use it ? –  Belun Nov 24 '10 at 9:57
@Belun, While I find it delightful that a discussion about tools nearly became an existential debate, I'm quite certain that you might be juxtaposing an inordinate amount of complexity on such a simple problem. How long depends entirely on you and your immediate need. –  Tim Post Nov 24 '10 at 10:14
"everything looks like a sore nail"... –  user1249 Nov 24 '10 at 10:23
My spoon is too big! –  adamk Nov 24 '10 at 22:03

9 Answers 9

up vote 9 down vote accepted

Expect things to go smoothly. If you have an object X and a hammer H, and H fails to drive X into a plank of wood W, it must become obvious to you that X is not a nail, and H is not the right tool to drive X into W.

share|improve this answer
pain-free sounds like a nice metric :) –  Belun Nov 24 '10 at 12:37
+1, but I'd add that taking longer than expected, or having to manually do the same thing over and over should also be warning signs. –  Larry Coleman Nov 24 '10 at 15:28
@Larry: exactly, whenever it feels like "there must be a better way to do that" it's time to look for a screwdriver –  user281377 Nov 24 '10 at 16:29
+1 for "expect things to go smoothly" - if they don't then you don't know what you're doing (for that specific problem) and you must learn –  Gary Rowe Nov 24 '10 at 17:05
This is what I see with junior developers. They try something, it doesn't work, they assume it's their own fault and keep beating their head against the wall. More senior people say "huh, this tool must be wrong somehow" and go find another way to do it. –  Kate Gregory Nov 24 '10 at 19:03

Tim Post nailed it in his comment.

Make sure that you either learn the basics of how to use other tools, or are at least aware enough of them that you know what they'd be good for.

This awareness will make you better able to judge the weaknesses of the tools you are using.

The other thing to realise is that sometimes using a non-ideal tool that you know how to use well, is better than you using the perfect tool badly.

share|improve this answer
to learn to use other tools is very broad idea. there are many tools and most are not so easy to master. there is limited time and limited number of neurons. can't just ruin them on random stuff. –  Belun Nov 24 '10 at 9:55
@Belun - I don't believe that you need to master them, I think you just need a good basic awareness of them. To extend the original metaphor, once I understand what a screwdriver is and does, I know the ways in which it is better than a hammer. At that point if I find a situation where based on what I know a screwdriver seems more appropriate, I can then look into the details of what I'd really need to implement that. –  Jon Hopkins Nov 24 '10 at 9:59
One problem is that you don't know what you don't know. I think you can not avoid this entirely. One approach is to have a broad but shallow knowledge. You can then deepen the most relevant fields when you need to. –  LennyProgrammers Nov 24 '10 at 11:20
I agree... You should be constantly looking for other tools. No craftsman worth his salt would be satisfied with a toolbox with one tool, no matter how good it is. –  Eric King Nov 24 '10 at 14:14
A jack of all trades is a master of none. –  adamk Nov 24 '10 at 22:04

Stay informed

You don't need to be a guru in the whole tools department, but if you stay informed, at least you've heard of the screwdriver and know where to look if you need it some day!

Read blogs, go to developer days, try other languages at home for fun or be active on StackOverflow? ;)

share|improve this answer

You must understand your tools

If you don't understand what your tools are for then you're not really a software craftsman, you're just blindly copying the actions of one. When you truly understand the nature of the tool, and therefore it's limitations, then you'll be much better placed to apply it where it is most effective.

You will also know when to leave it aside and use, or find, a different (perhaps better) tool.

share|improve this answer
Yes, I see this all the time with people who use ORMs. ORms in the hands of someone who understands what they are good for and what they aren't good for is great, ORMs in the hands of someone who uses them to avoid understanding databases - bad idea. –  HLGEM Nov 24 '10 at 17:01

I can't think of an advancement since the discovery of fire that didn't start with "There must be a better/easier way .." Except in science, where that is transformed to "There must be a better explanation .."

If you find yourself fighting your tools equally or more than the problem you hoped they would help you to solve, you need more tools. Have faith that your fellow programmer encountered a similar situation, and fashioned something much better suited for the task at hand.

I program mostly in C. I can't think of many things that I could not write using C, but I can think of many things that I wouldn't want to write in C. That's why my tool box also contains the following:

  • Python - For any kind of desktop app or rapid prototyping, or string intense stuff
  • Shell Scripting - For automating darn near anything
  • PHP - For when I need to make something web related and find myself too lazy to use Python
  • OCaml - When I need to go beyond a prototype and keep shooting myself in the foot with C
  • Various esoteric languages for when I want to amuse myself

I was almost not going to answer this, but then you said:

but suppose, i only know of the hammer. is screwdriver a tool ? does it exists yet ? how long to learn to use it ?

If you are fighting something, you should realize that there is probably a better way of doing it. That way might exist with the tool you are using .. or it may mean you need to look for something else.

As for the time / learning curve, learning is always an investment. Are you going to be confronting many similar problems in the future? Would you like to deal with them in 1/10 of the time with code that doesn't break so easily? Then yes, learn a new tool.

If your back is against the wall and you have no time to learn something new, then you will probably elect to muddle through it using what you know and (hopefully) finish it. Still, let that serve as incentive to spend some time learning something new.

I can say, from experience, it is easier to learn a new language or method when you have a very specific problem in mind. It's not "oh, gee, I wanna learn Python" .. it becomes "I need to learn the innards of twisted because I need to make a working client for this API and my hammer isn't cutting it!" If you study examples that actually help you do what you want to do, you learn much faster.

share|improve this answer

I find that (at least in the .NET world) podcasts are a great way to survey new technologies, so that you know about the screwdriver.

Hanselminutes and DotNetRocks are especially good.

share|improve this answer
+1 for the podcast idea of staying aware of your industry –  Belun Nov 24 '10 at 17:21

Get exposed to new stuff. You can talk to other people in the field, read blogs, read questions on SO, browse bookstore shelves, whatever. If you don't keep your eyes open, you won't know what's out there.

Once you've been exposed, you can learn more about what might help you.

And, to repeat something that lots of people have repeated in the past, get familiar with several different sorts of computer languages. You should be able to do procedural, object-oriented, functional, and declarative programming, at a minimum. Keep an eye out for things that you don't understand and puzzle you and learn about them.

share|improve this answer

Do things differently just for the sake of doing them differently. Some people will frown on this, but there's only one way to know if something works or not: try it out.

share|improve this answer

Every time you hear about a tool and think "that's a terrible idea.": Go use that tool. Many times your initial reaction to the tool indicates not how bad it is, but how little you understand.

  • Think that significant whitespace is a terrible idea: Use python for a while.
  • Think that dynamic typing will produce bugger programming: Use a programming language with dynamic typing.
  • Think that Aspect Oriented Programming will result in a terrible mess of a code base?: Try using AOP on a project
  • Think expressing an entire program as being a function of its input is a terrible idea?: Try Haskell
  • Think running on a VM will be too slow?: Try Java

Once you have tried it, then you can judge whether it works for you.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.