Blog: Learning to think like a programmer.

Views:
18170

Being a moderator here on the phpfreaks.com forums I have been witness to many newcomers to programming jumping to the conclusion that learning to program may just be as simple as learning a programming language. I'm here to say its not.

Sure, a big part of programming is knowing how your language of choice works, what it's functionality is capable of and how to piece it all together, but In my opinion, of bigger importance is the idea of logical thinking.

All too often I see people who have just finished reading that new php book they got for their birthday stroll into a message board and ask 'How do I build a forum?'. I've read these books too, and to be honest, I don't think any of them have emphasised the importance of logical thinking and breaking your feature set down into smaller pieces. Nor do they mention the amount of time you might save in doing so.

Why search for a good tutorial on building a registration system using php5 when if you've learnt to break down the problem you wont need it?

As an example, Joe has recently picked up php's syntax, is quite comfortable with how to use the manual to look up functionality and now wants to build a login system for his website. Having not learnt the importance of logical thinking and having no clue where to start he posses the question 'How do I build a login system?'. He gets a few responses pointing him to some useful tutorials and his on his way. With that feature complete he now wants to add the ability to validate his users are providing him with a valid email address, but with no clue where to start he posses another question 'How do I validate a users email address?'. Again he is pointed to some useful tutorials but because he lacks ability to piece together the information he ends up back at square one with the new question 'How do I build a login system validating a users email address?'.

This story could go around and around with Joe eating up valuable programming time reading more and more tutorials which may eventually get the job done, but really leave him not much the wiser. The next project he embarks on may require an entirely new feature set and while some of what Joe has learnt may be of use, it is likely he is going to need to refer to those same tutorials he has now bookmarked for prosperity.

On the other hand, Mark who has read the same book as Joe but has also had it drummed into him that all problems can and should be broken down into bite size pieces. Again wanting to add a login system to his website he posses the questions to himself....

q) What functionality makes up a login system?

    a) Registration?

        q) What functionality makes up registration page?

            a) Take user submitted details and store them for later reference?

                q) How do I enter user submitted data into a database?

                    a) I remember reading about that in my book, I'll use that as a reference.

    a) Verification?
        ...
    a) Identification?
        ...

Even with this simple scenario we can see that Mark is well ahead of Joe. He is thinking through the issue piece by piece and is able to simply refer back to his still in good tact book for explanations of the syntax some things might require. The entire problem doesn't seem as overwhelming as that of Joe's 'How do I build a login system?' And in the end, because Mark has been through the thought process and understands how all the pieces fit together adding new functionality will be a simple task of posing the right question, in the right position.