On Saturday 24 April 2010 10:46:33 Nathan Rixham wrote:
> David McGlone wrote:
> > On Friday 23 April 2010 07:45:16 Michiel Sikma wrote:
> >> On 23 April 2010 13:15, David McGlone <da...@dmcentral.net> wrote:
> >>> Is there a good strategy to studying PHP?
> >>>
> >>> For instance, is there a way to break everything down into small
> >>> managable topics?
> >>>
> >>> --
> >>> Blessings,
> >>> David M.
> >>
> >> Just build what you want to build and look things up when necessary. The
> >> biggest part of learning any language is becoming able to creatively
> >> solve problems within its realm of possibilities, and that's something
> >> you can't really learn just by reading and solving textbook problems.
> >> Hands-on experience is a very important key to understanding.
> >>
> >> Keep an open mind, ask people for answers if things get difficult,
> >> always assume that there's a better way to do something, and in a while
> >> you'll be able to write perfectly decent programs.
> >
> > This is the route I have been following for the past couple years and I
> > have always assumed there is a better way to do something and that is, in
> > a way what makes me lose confidence.
> >
> > I always feel like my code is crap and sometimes even ashamed to even
> > show any of it.
> Hi David,
> Really good to see somebody asking for honest advice on a v important
> matter :)

Thank you.

> First, if I may, I'd like to suggest that being ashamed to show your
> code is never going to be a productive way to work, rather the more code
> you show, the more feedback you will get on your code, and often with
> examples of alternative ways to do it - posting snippets and
> opensourcing are great ways of crowd sourcing solid feedback.

This is very true!

> Next, saying your code is crap, we all feel like that sometimes, but
> it's critical to note that if your code does the job it's supposed to,
> then it's a success! A few months ago I was questioning myself again and
> wrote this: http://webr3.org/blog/general/the-wall/ - the point is it's
> a good thing to question yourself, it's a good thing to take everything
> in to consideration, and often I (used to) find myself looking at very
> short procedural ways of doing things and think.. "why am i making all
> these classes"; it's our job as programmers to know when to implement
> something in 10 quick lines that are easy to maintain, and when to
> create an all singing and dancing framework type affair, pros and cons
> to each, and there is no "One True Way" TM of doing things - each bit of
> code is very much dependent on context, scenario and maintenance costs.
> Okay, on to your specific questions!
> We can break this down in to small(~ish) common junks, and which you
> study, take further and in what order is entirely up to you:
> General Coding
> This is the stuff that translates to almost every language, for loops,
> echo'ing, simple code optimisation and basically just how to script and
> program - I'll assume that after two years you've got this nailed better
> than any book can teach you, from here it's just experience and picking
> up tricks on the way, so generally no need to worry!
> As you know php is a specific language, and the best way to learn
> everything php specific, is literally to read the manual, from start to
> finish, a few times, and keep referring back to it, if you see something
> you haven't actually used before then give it a quick go in a short 5-10
> line script and have a play, the 2 minutes it takes will be more than
> worth it (by doing it, it'll get engrained in you).

Wow, I've done this and didn't even realize it. Just a few weeks ago, I was 
trying to understand about how $this -> worked. 

I think I posted that over on php-db. I learned it was related to classes, so 
I dug into classes in the php manual and just wrote code and played with it. I 
did get a better understanding of the whole picture, but probably not enough 
to fully feel comfortable.

> Aside: in every project i do, and at all times i have a test.php where I
> literally just try out ways of doing things and snippets of code, once
> I'm done i stick an exit; before it then do the next snippet above it,
> this way i always have one nice file of snippets in every project to
> refer back to - they often come in handy for helping on this list
> actually, and in fact sometimes are from peoples code on this list!

Great Idea! I probably would have never thought of this. How do you include 
these snippets into your actual work to see if they work? Do you just run the 
file or make functions and just include the function in the code you are 
working on?

> Coding Standards
> One of the biggest factors of feeling your code isn't good enough, is by
> not using any coding standards,

This is absolutely what I have learned in the past couple months. I bought 2 
books called Beginning PHP and MySQL E-Commerce From Novice to Professional 
1st and 2nd edition by Cristian Darie and these 2 books build a T-Shirt web 
site from start to finish, and I realized with these books just how important 
organizing your code and following standards is.

> this is pretty simple stuff but makes
> your life a lot easier, and code a lot cleaner - even crap broken code
> comes across a lot better when it's nicely formatted lol. A good IDE can
> help you here, as for which coding standards that's up to you, but you
> can check you are adhering to them by using "php code sniffer" -
> personally I opt for a slightly modified version of zend coding
> standards with the odd bit of extra spacing around params etc.

It's sad as long as I've been pushing myself to learn PHP, and studying 
anything I can get my hands on, I've never heard of "php code sniffer".

On a side note: the trick is to make the code look so darn gibberish, that it 
makes whoever had written it look like a genius ;-) 
> Paradigms & Design Patterns
> A bit of familiarity with programming paradigms is always a good thing
> http://en.wikipedia.org/wiki/Programming_paradigm
> In PHP we use Procedural and Object Orientated (Class Based)
> If you do OO then it's also very very useful to read up on all the
> Object Orientated subjects though especially "Separation of Concerns",
> familiarity of Martin Fowler's enterprise patterns
> http://martinfowler.com/ is also a good thing, there is also a Java
> pattern guide that's most useful
> http://java.sun.com/blueprints/patterns/ and many transfer over to OO PHP.
> Other Languages
> Yes :) one of the best ways to get good with your primary language (php)
> is to try out and use other languages, for instance if you were to put
> some focus in to javascript (ecmascript), scala, erlang, c, java and
> maybe something like as3 then I'm pretty sure your code and programming
> would improve ten fold I'm sure - I'm not suggesting you learn them all
> but a bit of focus and playing from time to time would be a very good
> thing indeed!

My first serious attempt at coding was  back when windows '95 was out. I tried 
to learn C++. I remember I was up for days just trying to figure out how to set 
the correct path in the compiler so my programs would compile and work. Since 
then I've only piddled around with C++, but here lately I have been seeing 
similarities and differences in PHP with what little I learned of C++.

> This is pretty critical if you're making websites, honestly how can we
> create th web if we don't know how it works? REST is the design behind
> HTTP (and not just some weirdy api where you use GET parameters) - in
> fact when i say pretty critical i mean it's entirely critical, the more
> you understand REST and the more familiar you are with HTTP then the
> better your websites, web apps, api's etc will be!
> HTTP: http://www.w3.org/Protocols/rfc2616/rfc2616.html
> HTTPbis (the updated version, work in progress, probably better to read
> to be honest): http://tools.ietf.org/wg/httpbis/
> Architecture of the worldwide web: http://www.w3.org/TR/webarch/
> )you can't argue w/ the makers of the web now can ya)
> http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

Thank you Nathan! I have bookmarked all the sites and will be reading all of 
them. Your words have inspired me to give it my all once again.

> leave it there.. but happy to continue if you need.

Thank you. You've probably given me enough to chew for months to come.

David M.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to