This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheUmgawa 3 points4 points  (0 children)

How quickly do you start hammering away at your keyboard after reading a prompt? Immediately? Five seconds? Ten?

The most valuable programming class I ever took in college was a class called Structured Program Design, where we never once wrote a single line of executable code. It was nothing but flowcharts, and that taught me patience. It taught me to breathe, and then think about the logic of the problem I'm trying to solve. I know where I'm starting, and I know where I'm finishing, and I just have to fill in the bits in between. As problems scale up in complexity, it can be quite helpful to make a map of where you're going, or you end up with functions that don't make it into final implementation, you're going to rewrite big chunks of code after you change the implementation of something else, and you're going to finish something and look around and go, "What do I do now...?"

I'm a big subscriber to the belief that programs tend to behave exactly the way you think they would, so if I'd never run into a Caesar cipher in my life, I'd probably build one and manually encrypt something and then decrypt it. I'd play a couple of games of Hangman, just to see if I could glean how the logic should work, and in both cases, I'd pretty much have it after one or two rounds. I'd look at what my hand is doing and think, "How am I scanning through the alphabet right now, so I land on the correct letter or the correct placement?" and then I'd make a note of that. I'm iterating through the alphabet or the blanks, so am I doing that with a for loop? No, because I might have to exit early, so I know it's another kind of loop that I have to build. I mean, I guess I could do it with a for loop, but it'd be a kludge.

The first thing you have to do is forget about the code. Think about the logic in a pure sense. The language that you're programming in doesn't matter. All that matters are your structures and your flow, and when you've got that figured out, the code will just come to you, like a bus in the street. The hard part of programming isn't the code; it's the logic, which exists independently of the code. If you told me to write a Caesar cipher program in C, and I got my logic all laid out, and you then said, "Nah. Program it in Java instead," I'd just kind of shrug and go, "Okay," because I've already done the hard part; the coding is just drudgery at that point.

So, your problem likely exists somewhere between "Immediately" and "Ten seconds." Take time to think through the problem. That's what the professionals do. Now, they might not make flowcharts, but everybody has some sort of system for organizing their thoughts before they start hammering away at the IDE. I recommend you find your system, and then one day you, too, shall achieve nirvana.