I gave a coworker the man page for a C function he hadn't used before, as well as some of the parameters for it. It interacts with parts of the system external to the application he was writing, and he was surprised and pleased that it worked the first time.
Then doubt set in.
He now worries that though it's working now it will fail in front of a customer - in other words, it's not 'hard-won' code.
I suspect many people learn the most about a function/class/etc by doing it wrong, and struggling with it until the light comes on and they understand it - then it becomes part of their toolbox.
- Has this happened to you, where you don't trust a piece of code you wrote that worked on the first run?
- If so, what happened later? (never failed, eventually found a corner case, failed, failed spectacularly, etc)
- What do you do to allay your fears?
In the absence of struggle, how do you learn the quirks of a new function/object/etc?
In the broader sense - very new programmers are often afraid and doubtful of their own work - even typing in an example verbatim will still result in a feeling of, perhaps, "I can't do this, I'm sure it's going to fail, etc" until something clicks and programming either makes sense, or they have simply overcome their fear. How do you mentor someone new to get past this point?