NYCPHP Meetup

NYPHP.org

[nycphp-talk] Learning to program the right way

Mark Armendariz lists at enobrev.com
Mon Jan 23 15:41:45 EST 2012


It seems this might be an unpopular opinion around here, but I think 
it's a great idea to include all of the above.  It teaches that while 
these things may be optional, the option is to remove them from your 
process, not to add them.  It's important that these ideas are 
introduced early so that when one tries to continue research on their 
own, they at least have some idea of what the hell people are talking 
about.  More importantly, I think it's a big deal to understand how all 
these things fit together.

I would otherwise recommend some sort of agnosticism towards your 
outside tools.  Show git, but mention and offer links to bzr, hg, svn.  
Show phpunit but mention and offer links to simpletest.  PHP and MySQL 
are tied at the hip because every blog title and book had the two welded 
together for years, which in many cases makes one think that other 
databases (or languages) would be incorrect without the other.

I agree with most responses here that it's the code is top priority and 
should remain the focal point.  But including these other subjects will 
help the reader get a broader view of what programming is all about.

On 01/23/2012 01:17 PM, Gary Mort wrote:
> One thing that has annoyed me more and more over time is the way books 
> and classes go about teaching /how/ to program in a language.
>
> They all start off with "Hello World" and then progress slowly form 
> there to more and more complicated things.  I've noticed that even 
> Ruby books, the poster child for unit testing, proceed in this manner.
>
> In short, they wait until /after/ someone has developed bad habits and 
> then introduce version control and unit testing as an afterthought.
>
> It seems to me that the /correct/ way to teach programming is to start 
> with a little version control, then do a little unit testing, and then 
> proceed to the coding.  Especially useful is to structure the course 
> so that the users experience just /why/ version control and unit tests 
> are a good thing.
>
> As such, I'm going to try to put together a course on learning to 
> program PHP the right way.
>
> It starts off with learning a minimal number of git commands[you don't 
> need to know them all, and there is no reason to confuse yourself at 
> this point!  All you need are "git clone...", "git commit...", and 
> "git push..." while not necessary is a nice to have.  This unit will 
> include cloning an existing code repository on github, making a 
> change, and commiting your change.
>
> The code should include a class or two /and/ some incomplete unit 
> tests for said class.
>
> The next step is learning some basic unit test commands, run the unit 
> tests on the code to see them working, demonstration of how to run the 
> checks so you can see what methods are not currently covered by unit 
> tests.
>
> Unit tests are fairly trivial bits of code, so the first introduction 
> to coding will be to add the missing unit tests.  Verify the 
> addition.  Commit the changes.
>
> After that, we can do the traditional "hello world" app....the RIGHT 
> way, ie make a unit test for it, then implement it.  Verify the new 
> code.  Commit the changes.
>
> Next up will be making some major functional changes to the code, 
> extending it, expanding it, etc.  At this point, we should be doing 
> some fairly radical, but simple, changes to the code where we will be 
> deleting entire sets of logic and replacing them with new sets - 
> including changing the unit tests first!  Verify the new code.  Commit 
> the changes.
>
> Following all these changes, we will now have to undo some of the 
> modifications and use the original code....  so a quick review now of 
> how to use git to browse through previous commits, review differences 
> in code, etc.  And of course, as always start with unit tests, verify 
> the changes, commit the changes.
>
>
> As you can see from the above, this also explains /why/ programming 
> books suck so much.  It's a lot of extra verbage to go step by step 
> through the testing/commit process - and programmers are by nature 
> lazy!  So they skip it.
>
> I'm curious if there are any other items people think should be 
> incorporated into this tutorial.
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show-participation




More information about the talk mailing list