My
last post motivated me to reiterate a point I tried to make. In that post, I said:
"You have to realize that code is not something magical that happens to do what you want as long as it's written in a certain way. When you code, you are providing instructions to something that can't read your mind and doesn't know what you want to do. So in your code you have to be explicit about the things you intend to do and what exactly it is that you're doing these things on. So if the code doesn't, in some way, incorporate an instruction or piece of information that anything or anyone would need in order to do the right task on the right thing, it couldn't possibly be correct."
In my experience, I find that some people "get it" and some people just don't. The latter, I'm afraid, don't make good coders. It's certainly not my intent to offend anyone, I'm only trying to say that some people don't seem to possess a certain manner of thinking that I think is crucial to a good coder. And that's fine - nobody excels at everything. If you're not a good coder, you're probably a good something (and whatever you're good at, chances are it can help you with your social life moreso than coding ever could).
I was once helping out a friend with a physics problem. It was something like figuring out how far an object went after being thrown straight off the top of a building X meters tall at a speed of Y meters per second. The person was frustrated and somewhat astonished that the right answer wasn't "just coming out" of a formula even though they never specified what the height of the building was anywhere.
I find that a common approach to problem solving (being physics or coding) is to mash and mangle anything that might make sense until you get something that seems to be correct. I came from a program where a lot of people were forced to take courses in programming. They hated it, claimed they "didn't get it" and admitted they were very bad at it. Here is what I often noticed about their approaches and beliefs regarding coding (perhaps being cogniscent of these kinds of things might make you a better coder):
- They say things like "It just needs to be this way. That's how it works, I don't know why. Just do it."
- They say "It's not doing what it's supposed to" (as if "it" is supposed to know).
- They almost always blame their hard time with coding on not knowing syntax. Obviously, everyone knows the difference between syntax and logic but some people just don't seem to be conscious of this difference all the time.
- They get overwhelmed by bigger tasks instead of dividing and conquering.
- They try to put together different lines of codes and different constructs that they learned assuming that they'll get something to work. "Let me try that while loop thing and just put this part in there and see if that makes it work...". (I swear to you I've encountered this. No further comment).
So how do you think like a coder? I don't know... I think you just do, or you don't.