Blogs

Learning to think like a programmer.

by Tony Quilkey on Jun 17, 2008 1:37:01 AM

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....

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.

Comments

I thought about writing a tutorial about thinking like a programmer.... Then I remembered how lazy I am.

Nice blog. Very interesting, and true. I was thinking about this the other day.... Users will come onto the forum all of the time and post questions that are just common sense... in a programmy way... If that makes sense, and they just didn't stop to think of what they're really trying to do.

Oh, I just happened to notice "tutorials and his on his way," by the way...

1. Corbin H on Jun 17, 2008 1:56:48 AM

How about checking your grammar : )~ LEARNT

oh my bad that must be uk's version of learned

2. mthomps71 on Jun 19, 2008 3:42:05 PM

You know as a designer learning to code I find myself constantly trying to learn. I guess I could understand your perspective if you know everything there is to know about .php and coding. Truth of the matter is people are looking to learn and what better way than to have someone help point them in the right direction. That is what makes the internet so great. I don't think one person on here could walk down the street and just start asking people programming questions and get help in what direction they need to go in order to learn. As a moderating I am quite surprised you would look down upon the newbies in this way and not give them a more consoling and helpful hand in becoming better programmers.

3. macrunning on Jun 20, 2008 1:21:51 PM

I think you may have missed the point. Point is, learning everything there is to know about a language will get you nowhere if you haven't learnt how to think a problem through. Its easy to think of a feature you wish to build (the end result), but leaning to step back and think of how that feature might get to that end result is where its at. Untill you can step through a problem in logical steps you will forever be asking others to do the thinking for you.

4. Tony Quilkey on Jun 22, 2008 3:51:35 AM

When I first started out I decided to create a portfolio for the projects I had completed over time. I sat down and thought about what features I needed to make the portfolio work. At first I didn't even touch a computer. I sat down with a pen and paper and wrote down and described everything I thought I needed. This included my database design and deciding what data types my database needed.

So, to all the new starters out there I recommend doing exactly what I did. Sit down and think before you code.

macrunning: I have been in the position of 'Joe' and it truly is a lot of wasted programming time. Instead of asking a question, sorting it, coming back and asking another question, rinsing then repeating. It is so much more productive to know what direction you are trying to head in.

5. wrathican on Jun 22, 2008 4:40:17 PM

nice discussion, well in my view, to be a good programmer you need to have logical thinking plus your passion and innovation and love for your work, until you don't love your programming job you can't be a productive programmer.

6. numan82 on Jun 23, 2008 12:36:25 PM

Even though it's not focused on php, I found this book very helpful in learning to think more like a programmer, and less like I was just hacking code together into scripts:

"How to Think Like a Computer Scientist: Learning with Python" at
http://www.greenteapress.com/thinkpython/thinkCSpy/

Another great resource for this is the "Head First Software Development" book from O'Reilly.

7. jdcpar5 on Jun 26, 2008 9:48:18 AM

Note to mthomps71

He learned
He has learnt

8. Barry Andrew on Jun 30, 2008 9:15:26 PM

I think the word to be emphasized here, which has been surprisingly absent, is APPLICATION. Before you can create with your new found knowledge you first understand the appropriate method(s) with which to apply that knowledge. In contrast to this brief article, the tutorials you find are actually a very good starting point for understanding application. By seeing how others have utilized the language a relative "noob" with at least some common sense can work out on his/her own the best way to apply new found knowledge.

I agree that merely copying the work in these examples is no way to accomplish true application ability but by studying and modifying you learn much quicker than by merely breaking things down and going it alone with only what you've studied.

9. Greg Davis on Jul 4, 2008 8:10:56 PM

very good topic i think. and good point too you do need to understand php to be able to think this way though but for someone that reads the book then just puts it aside and trys to figure things out will not be very successful. the point is learn the basics then when you try something more complicated you have a base. and if you know what your application needs to do then you can seek out the functions and the syntax that you need for that action. if it's in your book that you read then you have a good start if not then turn to the internet. and this is coming from someone that learned the bulk of my php programming from tutorials online.

10. dogbiter on Jul 5, 2008 12:15:29 AM

As always there are two sides of the coin. Yes, it's difficult, if not impossible, to design and code a complex login system without proper planning. On the other hand, planning a design without knowing anything about coding isn't that easy either. It's sort of like planning a journey - you have to know where you're going before you decide how to get there but if you don't know what means of transportation are available you might not get anywhere.
My point being that the better approach for Joe would be to learn programming by walking through some of all the great tutorials available here and elsewhere. Then, when he's beginning to understand a little of what programming is about, he could start planning and designing his complex system. thta's pretty much how I started out some 5 years ago. I built a site for a CS clan by converting an asp/access driven site to php/mysql. After that I've started out on a personal site a few times but I always end up biting off more than I can chew...

11. Led Zled on Jul 17, 2008 8:15:17 AM

[quote=Corbin H]I thought about writing a tutorial about thinking like a programmer.... Then I remembered how lazy I am.[/quote]

Beging lazy is a requirement of being a programmer. It especially helps with OOP you build stuff so you can be lazy later and never have to write the same thing again.

Good blog. I agree with you about books so many tell you how to learn a language but few teach you how to program. I am yet to find ANY documentation on BEST PRACTICE and i have been in the game for a good 6-8 years.

12. knowj on Aug 15, 2008 2:27:38 PM

What you're saying is so very correct and important - Joel Spolsky too says the same thing - http://www.joelonsoftware.com/articles/fog0000000245.html
( NOTE: in my opinion, the small reference to evidence-based scheduling is probably more reasonably fitting to teams and corporations making huge products.)
I personally yearn for the day that I start making plans that actually get implemented on time ;-)
Breaking down tasks and asking lots of questions - very much needed.

"Point is, learning everything there is to know about a language will get you nowhere if you haven't learnt how to think a problem through. Its easy to think of a feature you wish to build (the end result), but leaning to step back and think of how that feature might get to that end result is where its at. Until you can step through a problem in logical steps you will forever be asking others to do the thinking for you."
Needs to go into the main article :-P

13. activeserver on Oct 25, 2008 8:23:52 AM
Login or register to post a comment.