Re: [PHP] Structured PHP studying

2010-04-25 Thread tedd

At 3:01 PM +0100 4/24/10, Ashley Sheridan wrote:

I look at some code I did a while back and shudder. It started off well
enough, but then feature creep set in and now it looks like a creation
of Frankenstein! I think it happens to all of us at some point, it just
depends how well we deal with it. I'd rather have less then stellar code
than have to tell a client it's going to take more time to add a feature
and then have them go elsewhere.

Thanks,
Ash


Ash et al:

Wait until you have 40 years of code to look back at. I'm not ashamed 
of any of any of my code for it was best that I could do I with the 
equipment I had.


Of course, reviewing the web sites I did in 1995, and comparing them 
with with I do today gives me pause. However, the tools that were 
available then were not what they are today.


So, when you are reviewing/analyzing your past work, you really have 
two things to consider: 1) What you created; 2) and the technology of 
the time.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Structured PHP studying

2010-04-25 Thread David McGlone
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!

 PHP
 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 

Re: [PHP] Structured PHP studying

2010-04-25 Thread paragasu
 Just build what you want to build and look things up when necessary.
I did exactly like this. My first application is a forum. It never made it
to production,
but i learn a lot. And i am glad i learn it this way. It is a bit costly but
fun.


On Sun, Apr 25, 2010 at 11:01 PM, David McGlone da...@dmcentral.net wrote:

 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!
 
  PHP
  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 

Re: [PHP] Structured PHP studying

2010-04-25 Thread David McGlone
On Saturday 24 April 2010 10:01:03 Ashley Sheridan wrote:
 On Sat, 2010-04-24 at 07:14 -0400, 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.
 
  --
  Blessings,
  David M.

 For personal sites, I think as long as the code works, and doesn't have
 any glaringly obvious security holes in, then it should be fine.
 Personal sites tend not to have a huge amount of traffic, so speed
 doesn't really become an issue unless you're doing something totally
 crazy (like generating all of your header images on the fly with PHP for
 example without any caching)

 For commercial sites, more time should be spent on security and testing,
 and working over things in your head about how the site is going to get
 used. If an area of the site that you feel is going to be very popular
 will be busy, then is creating a lot of large objects and making many DB
 calls such a great idea?

In a sense it seems to me that this is the bridge I'm trying to cross. 
Developing personal sites aren't all that hard, because they don't require 
much functionality and most of the complexity shouldn't be too hard to solve 
with a little PHP. 

But when it comes to commercial sites, the complexity is even greater and also 
more intimidating to me.


 I look at some code I did a while back and shudder. It started off well
 enough, but then feature creep set in and now it looks like a creation
 of Frankenstein! I think it happens to all of us at some point, it just
 depends how well we deal with it. I'd rather have less then stellar code
 than have to tell a client it's going to take more time to add a feature
 and then have them go elsewhere.

To me my code is more like a bunch of kiddie scripts thrown together with an 
occasional thing I like to call smart block (a block of code that I 
concocted and wrote, that works and actually makes me feel proud of) LOL

here's a snippet of code I wrote:

$directories = array('gemstone', 'bella', 'passage', 'sedona', 'deepstar', 
'crystalline');


foreach ($directories as $directory){
echo h1span$directory/span/h1;



$mydir2=opendir(images/laminate/Wilsonart_Laminate_Colors/$directory);
$cats2=array();

while(($cat2=readdir($mydir2)) !==false){
if ($cat2 != .  $cat2 != ..  
strpos(strtolower($cat2),-thumb.jpg) 
!== false){
array_push($cats2, $cat2);

echo img 
src=images/laminate/Wilsonart_Laminate_Colors/$directory/$cat2 
onclick=Another_Big_One(this)nbsp;;
}
}
closedir($mydir2);

} 

To tell you the truth, I have absolutely no clue how I did it. There's 
probably a much much better way to do it, but at my current level, I was 
surprised I even wrote this.

There is only 1 thing I don't particularly like about it. That is, the fact I 
used some HTML, but it doesn't bother me too much because it was way before I 
knew much about separating the presentation from the logic, but now days I 
have come to love SMARTY.

SMARTY forces me to separate things and to work in tiers and in turn forces me 
into standards and organization of my code. (I hope I explained that 
correctly).

-- 
Blessings,
David M.

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



Re: [PHP] Structured PHP studying

2010-04-25 Thread Nathan Rixham
David McGlone wrote:
 On Saturday 24 April 2010 10:46:33 Nathan Rixham wrote:
 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?

typically I use it for handling little scenarios, will try out a couple
of approaches and then whichever is best I'll incorporate in to my
script/class/method/function and just leave the test code in the
test.php file for future reference.

each little snippet of code we make has one task to do, normally given
the values (x,y,z) create something new, perform some calculation or
take some action and return the status - regardless of how we wrap that
up in the end, and where we get our values from, the code in the
middle will typically be the same; so if I write:

$tests = array( 'nathan', 'nath.an', 'nat:@han$%^' );
foreach( $tests as $test ) {
   echo trim( preg_replace( '/[^a-z.]/im' , '' , $test ));
}

in my test.php to figure out how to strip all non alpha chars, then when
I'm happy with the results, I'll simply write a function/method to do
that task in my real app.

function( $string )
{
  return trim( preg_replace( '/[^a-z.]/im' , '' , $string ));
}

to run the test.php I just use my IDE, but you could easily just php -f
test.php

the main point of doing this is that after I've tried one approach and
am ready to try the next i stick and exit; before it, this way it won't
run, but its catalogued there - kinda like taking notes back when we
were in school and show how you worked it out, always useful to look
back 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.

http://framework.zend.com/manual/en/coding-standard.html
http://pear.php.net/package/PHP_CodeSniffer/redirected

netbeans also has support and this for eclipse http://www.phpsrc.org/
(which i haven't used yet) - personally I use phpUnderControl for
automated building and have ant tasks set up to run all my code through
php lint check, php code sniffer, php doc and to run all unit tests,
then if it's okay it is automatically deployed out to my tests sites,
and if not informs me that the build (code) is broken.

 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 ;-)

actually mate that the complete opposite of what you want, and a sign of
very very poor coding indeed ;) you want the code to be as simple and as
clean as possible, minimal whilst crystal clear - small short clean
functions that do one task properly and only do that one task - that's
the sign of a good coder and one who has mastered (or is mastering) the
art of programming.

incidentally the art of computer programming is exceptionally good if
you have the time and money:
http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming
http://www.amazon.com/Art-Computer-Programming-Volumes-Boxed/dp/0201485419


 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.

brilliant! :D

Best,

Nathan

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



Re: [PHP] Structured PHP studying

2010-04-25 Thread David McGlone

Another one from this morning that didn't seem to make it to the list.

On Saturday 24 April 2010 10:01:03 Ashley Sheridan wrote:
 On Sat, 2010-04-24 at 07:14 -0400, 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.
 
  --
  Blessings,
  David M.

 For personal sites, I think as long as the code works, and doesn't have
 any glaringly obvious security holes in, then it should be fine.
 Personal sites tend not to have a huge amount of traffic, so speed
 doesn't really become an issue unless you're doing something totally
 crazy (like generating all of your header images on the fly with PHP for
 example without any caching)

 For commercial sites, more time should be spent on security and testing,
 and working over things in your head about how the site is going to get
 used. If an area of the site that you feel is going to be very popular
 will be busy, then is creating a lot of large objects and making many DB
 calls such a great idea?

In a sense it seems to me that this is the bridge I'm trying to cross. 
Developing personal sites aren't all that hard, because they don't require 
much functionality and most of the complexity shouldn't be too hard to solve 
with a little PHP. 

But when it comes to commercial sites, the complexity is even greater and also 
more intimidating to me.


 I look at some code I did a while back and shudder. It started off well
 enough, but then feature creep set in and now it looks like a creation
 of Frankenstein! I think it happens to all of us at some point, it just
 depends how well we deal with it. I'd rather have less then stellar code
 than have to tell a client it's going to take more time to add a feature
 and then have them go elsewhere.

To me my code is more like a bunch of kiddie scripts thrown together with an 
occasional thing I like to call smart block (a block of code that I 
concocted and wrote, that works and actually makes me feel proud of) LOL

here's a snippet of code I wrote:

$directories = array('gemstone', 'bella', 'passage', 'sedona', 'deepstar', 
'crystalline');


foreach ($directories as $directory){
echo h1span$directory/span/h1;



$mydir2=opendir(images/laminate/Wilsonart_Laminate_Colors/$directory);
$cats2=array();

while(($cat2=readdir($mydir2)) !==false){
if ($cat2 != .  $cat2 != ..  
strpos(strtolower($cat2),-thumb.jpg) 
!== false){
array_push($cats2, $cat2);

echo img 
src=images/laminate/Wilsonart_Laminate_Colors/$directory/$cat2 
onclick=Another_Big_One(this)nbsp;;
}
}
closedir($mydir2);

} 

To tell you the truth, I have absolutely no clue how I did it. There's 
probably a much much better way to do it, but at my current level, I was 
surprised I even wrote this.

There is only 1 thing I don't particularly like about it. That is, the fact I 
used some HTML, but it doesn't bother me too much because it was way before I 
knew much about separating the presentation from the logic, but now days I 
have come to love SMARTY.

SMARTY forces me to separate things and to work in tiers and in turn forces me 
into standards and organization of my code. (I hope I explained that 
correctly).

-- 
Blessings,
David M.


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



Re: [PHP] Structured PHP studying

2010-04-24 Thread David McGlone
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.

-- 
Blessings,
David M.

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



Re: [PHP] Structured PHP studying

2010-04-24 Thread David McGlone
On Friday 23 April 2010 10:15:46 Paul M Foster wrote:
 On Fri, Apr 23, 2010 at 07:15:11AM -0400, David McGlone wrote:
  Is there a good strategy to studying PHP?
 
  For instance, is there a way to break everything down into small
  managable topics?

 Obviously, a good book will help. I'd recommend O'Reilly's Programming
 PHP. Some of this also depends on whether you have a background in
 programming. It's easier if you already know how to code in a different
 language; then you really mostly need to know the differences between
 the languages.

 If you want to learn without the benefit of a book, then I'd suggest
 looking over existing beginning programming books for various languages.
 My observation is that they generally follow a pattern. They deal with
 variable naming and types, then legal operations on those types, then
 control structures, then functions, etc. (That may not be accurate; as I
 said, look over the books themselves.) Most/all of this information can
 be obtained from the php.net site.

 Ashley's suggestion of coding a project is an outstanding idea. Coding
 is a practical art, and requires practical application to be worth
 anything.

I have coded a couple sites. One for my brother-in-law, but I hate that site 
so bad, I'm ashamed to even say I did it.

He chose the layout and colors and told me exactly where he wanted everything, 
and it's IMHO absolutely horrible. 

There is some code that I wrote for that site that did make me feel good for 
coming up with and although it works, most of the code for that site gets on 
my nerves. It gives me the feeling that it's very unorganized, and poorly 
written.

-- 
Blessings,
David M.

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



Re: [PHP] Structured PHP studying

2010-04-24 Thread Jason Pruim


On Apr 24, 2010, at 7:14 AM, 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.


I feel the some way sometimes... when I look back on some of the stuff  
that I wrote when I first started compared to today it's amazing  
the difference in such a short period of time... But I take comfort in  
knowing that I have stuff looking nicer then it was when I started...  
I'm making progress :)





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



Re: [PHP] Structured PHP studying

2010-04-24 Thread Ashley Sheridan
On Sat, 2010-04-24 at 07:14 -0400, 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.
 
 -- 
 Blessings,
 David M.
 


For personal sites, I think as long as the code works, and doesn't have
any glaringly obvious security holes in, then it should be fine.
Personal sites tend not to have a huge amount of traffic, so speed
doesn't really become an issue unless you're doing something totally
crazy (like generating all of your header images on the fly with PHP for
example without any caching)

For commercial sites, more time should be spent on security and testing,
and working over things in your head about how the site is going to get
used. If an area of the site that you feel is going to be very popular
will be busy, then is creating a lot of large objects and making many DB
calls such a great idea?

I look at some code I did a while back and shudder. It started off well
enough, but then feature creep set in and now it looks like a creation
of Frankenstein! I think it happens to all of us at some point, it just
depends how well we deal with it. I'd rather have less then stellar code
than have to tell a client it's going to take more time to add a feature
and then have them go elsewhere.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Structured PHP studying

2010-04-24 Thread Nathan Rixham
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 :)

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.

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!

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

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!

Coding Standards
One of the biggest factors of feeling your code isn't good enough, is by
not using any coding standards, 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.

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 

Re: [PHP] Structured PHP studying

2010-04-24 Thread Ashley Sheridan
On Sat, 2010-04-24 at 15:46 +0100, 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 :)
 
 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.
 
 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!
 
 PHP
 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).
 
 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!
 
 Coding Standards
 One of the biggest factors of feeling your code isn't good enough, is by
 not using any coding standards, 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.
 
 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
 

[PHP] Structured PHP studying

2010-04-23 Thread David McGlone
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.


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



Re: [PHP] Structured PHP studying

2010-04-23 Thread Peter Lind
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?

The Zend study guide might be a place to start - not for free thought,
so there may be better options (it's also directed at getting Zend
certified, so it's covering the stuff you need to know for that, not
connected things).

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP] Structured PHP studying

2010-04-23 Thread Ashley Sheridan
On Fri, 2010-04-23 at 07:15 -0400, David McGlone 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.
 
 


I started the way I guess most people did: from a basic book which broke
things up as it saw best. Obviously some books are better than others; I
won't mention any here as there are quite a few threads about good PHP
books.

From there, I just looked into what I thought I needed to know as I came
across it. It's a bit haphazard, but it did the trick.

Mostly though, I think if you find a good book, that should break things
down well enough that anyone can pick it up and follow along. You don't
have to follow a book linearly though, I found myself often focusing in
more depth into something a book only mentioned briefly because it
either sounded interesting or I needed to know more for a project.

Bit of a ramble there, but maybe it'll help?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Structured PHP studying

2010-04-23 Thread Michiel Sikma
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.

Michiel


Re: [PHP] Structured PHP studying

2010-04-23 Thread Jay Ess

David McGlone wrote:
Is there a good strategy to studying PHP? 

For instance, is there a way to break everything down into small managable 
topics?


  
My way of learning a new language is to decide on a small project to 
code and then learn just that i need to do for that exact feature i 
implement.
That works best if you already has some knowledge in computer 
programming. And when i have grasped sufficiently i can dig into texts 
on the net for deeper understanding of the language.





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



Re: [PHP] Structured PHP studying

2010-04-23 Thread Paul M Foster
On Fri, Apr 23, 2010 at 07:15:11AM -0400, David McGlone wrote:

 Is there a good strategy to studying PHP?
 
 For instance, is there a way to break everything down into small managable
 topics?

Obviously, a good book will help. I'd recommend O'Reilly's Programming
PHP. Some of this also depends on whether you have a background in
programming. It's easier if you already know how to code in a different
language; then you really mostly need to know the differences between
the languages.

If you want to learn without the benefit of a book, then I'd suggest
looking over existing beginning programming books for various languages.
My observation is that they generally follow a pattern. They deal with
variable naming and types, then legal operations on those types, then
control structures, then functions, etc. (That may not be accurate; as I
said, look over the books themselves.) Most/all of this information can
be obtained from the php.net site.

Ashley's suggestion of coding a project is an outstanding idea. Coding
is a practical art, and requires practical application to be worth
anything.

Paul

-- 
Paul M. Foster

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