I just finished reading Test Driven Development: By Example by Kent Beck (more on this later because this has really changed my workflow) and as I was reflecting on the concepts explained in the book I've started to wonder if people are learning to program all wrong.

When I learned to program in an academic setting (over a decade ago), we learned the basics of programming first (if block, for loop, functions, etc.) and then object oriented programming. This makes sense because it allows you to quickly write programs that do something but I think it teaches you the "wrong" way to structure your code. I think because of this some of the programmers I've worked with have been really good at writing code that can be used in one place (and can be copied and pasted into others :-)) but haven't always been good at writing code that can be unit tested and reused without duplication.

I've also had a problem with how each assignment is "new" and doesn't build on itself, which is completely unlike any of my day to day work. Most of the time I don't get to throw out the last weeks worth of work in order to add a new feature (although it has happened).

I also try to help out on /r/PHPhelp and some of code posted there is SCARY unmaintainable. My guess is that most people posting to /r/PHPhelp are actually self taught so they need the most help. :-)

I wonder if the 'correct' way to teach programming is via a Test Driven Development project that builds on itself. The teacher/TA can provide a test suite with existing tests and the student can slowly uncomment out test cases and implement the code required by the test. Then as they progress in the semester the teacher can provide less and less test suite up front and then they have to create it.

I wonder if people would even seek this out or are the people who are learning to program not even interested...