0
Good Practice in PHP Or "Things I Wish New Recruits Knew"
About Me <ul><li>Lorna Mitchell
Twitter: @lornajane
PHP consultant, trainer, and author
I live in Leeds
Website:  http://lornajane.net
Book:  http://sitepoint.com/books/phppro </li></ul>
Today's Outline <ul><li>Software Development Lifecycle
Databases
Source Control
Documentation
Open Source </li></ul>
Software Lifecycles
Waterfall
Waterfall
Agile <ul><li>Many different interpretations
Some or all of: </li><ul><li>iterative
customer involvement
product is always working
done in bursts called &quot;sprints&quot;
spec can change (in a controlled way) </li></ul></ul>
Databases
Databases <ul><li>Not a dumping ground
Often your application bottleneck
Worth understanding </li></ul>
Tools <ul><li>phpMyAdmin </li><ul><li>http://phpmyadmin.net </li></ul><li>Command Line </li><ul><li>powerful
well-documented </li></ul></ul>
Normalised Forms <ul><li>Guidelines for good table design
1 st  Normal Form </li><ul><li>no repeating groups (e.g. comma separated lists) </li></ul><li>2 nd  Normal Form </li><ul><...
Indices <ul><li>An index allows MySQL to quickly find things
Foreign key contstraints
Columns used in where clauses </li></ul>
EXPLAIN <ul><li>MySQL command
Which indexes are used
What kind of indexes
Number of rows scanned
Great for diagnosing slow queries </li></ul>
Source Control
Upcoming SlideShare
Loading in...5
×

Things I wish web graduates knew

2,572

Published on

Slides from a talk I gave to local students studying PHP, about some key skills, open source, and the importance of learning to help themselves.

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,572
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
42
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "Things I wish web graduates knew"

  1. 1. Good Practice in PHP Or &quot;Things I Wish New Recruits Knew&quot;
  2. 2. About Me <ul><li>Lorna Mitchell
  3. 3. Twitter: @lornajane
  4. 4. PHP consultant, trainer, and author
  5. 5. I live in Leeds
  6. 6. Website: http://lornajane.net
  7. 7. Book: http://sitepoint.com/books/phppro </li></ul>
  8. 8. Today's Outline <ul><li>Software Development Lifecycle
  9. 9. Databases
  10. 10. Source Control
  11. 11. Documentation
  12. 12. Open Source </li></ul>
  13. 13. Software Lifecycles
  14. 14. Waterfall
  15. 15. Waterfall
  16. 16. Agile <ul><li>Many different interpretations
  17. 17. Some or all of: </li><ul><li>iterative
  18. 18. customer involvement
  19. 19. product is always working
  20. 20. done in bursts called &quot;sprints&quot;
  21. 21. spec can change (in a controlled way) </li></ul></ul>
  22. 22. Databases
  23. 23. Databases <ul><li>Not a dumping ground
  24. 24. Often your application bottleneck
  25. 25. Worth understanding </li></ul>
  26. 26. Tools <ul><li>phpMyAdmin </li><ul><li>http://phpmyadmin.net </li></ul><li>Command Line </li><ul><li>powerful
  27. 27. well-documented </li></ul></ul>
  28. 28. Normalised Forms <ul><li>Guidelines for good table design
  29. 29. 1 st Normal Form </li><ul><li>no repeating groups (e.g. comma separated lists) </li></ul><li>2 nd Normal Form </li><ul><li>decouples entities and links them by relationship (e.g. customer data separate from order) </li></ul><li>3 rd Normal Form <- good enough! </li><ul><li>removes redundancy and dependent information </li></ul></ul>
  30. 30. Indices <ul><li>An index allows MySQL to quickly find things
  31. 31. Foreign key contstraints
  32. 32. Columns used in where clauses </li></ul>
  33. 33. EXPLAIN <ul><li>MySQL command
  34. 34. Which indexes are used
  35. 35. What kind of indexes
  36. 36. Number of rows scanned
  37. 37. Great for diagnosing slow queries </li></ul>
  38. 38. Source Control
  39. 39. Using Source Control <ul><li>Create a repository, add project
  40. 40. Check out project
  41. 41. Make changes
  42. 42. Update to get other changes
  43. 43. Commit changes to repo </li></ul>
  44. 44. svn log ------------------------------------------------------------------------ r3 | lornajane | 2010-04-25 10:32:09 +0100 (Sun, 25 Apr 2010) | 1 line adding documentation notes ------------------------------------------------------------------------ r2 | lornajane | 2010-04-22 09:07:56 +0100 (Thu, 22 Apr 2010) | 1 line outlining source control and design patterns sections ------------------------------------------------------------------------ r1 | weierophinney | 2010-03-30 17:37:27 +0100 (Tue, 30 Mar 2010) | 1 line Added readme with outline ------------------------------------------------------------------------
  45. 45. svn diff Index: README.txt =================================================================== --- README.txt (revision 3) +++ README.txt (revision 4) @@ -31,12 +35,20 @@ to share ideas to raise profile to be told you're doing it wrong! + (pulling up examples off our own blogs, if connection allows) Testing (Matthew) QA tools and CI including code analysis, mess detection, etc (Lorna - QA tools; Matthew - CI) + Static analysis + code sniffer + demo examples, find a suitable small codebase (joindin?) + mess detector + demo examples + what else? + Deployment
  46. 46. Source Control Tools <ul><li>Subversion (svn) </li><ul><li>http://subversion.apache.org/ </li></ul><li>Git (git) </li><ul><li>http://git-scm.com/ </li></ul><li>Mercurial (hg) </li><ul><li>http://mercurial.selenic.com/ </li></ul></ul>
  47. 47. Accessing Source Control <ul><li>IDE Plugins
  48. 48. Trac ( http://trac.edgewall.org/ )
  49. 49. TortoiseSVN </li><ul><li>TortoiseGit
  50. 50. TortoiseBzr
  51. 51. TortoiseHg </li></ul></ul>
  52. 52. Centralised Source Control user repo user user user
  53. 53. Centralised Source Control <ul><li>Single repo (repository)
  54. 54. Always commit to central
  55. 55. Can branch centrally </li></ul>
  56. 56. Distributed Source Control repo repo repo repo repo
  57. 57. Distributed Source Control <ul><li>Many repos
  58. 58. Commit to local repo
  59. 59. Share changes between anywhere
  60. 60. No central point </li></ul>
  61. 61. What If I Don't Have Source Control? <ul><li>Get some :)
  62. 62. Install subversion
  63. 63. Use a hosted solution </li></ul>
  64. 64. Documentation
  65. 65. API Docs <ul><li>Documentation generated from source code itself
  66. 66. Follows code structure </li><ul><li>classes
  67. 67. inheritance
  68. 68. methods
  69. 69. parameters </li></ul></ul>
  70. 70. PHPDocumentor
  71. 71. PHPDocumentor <ul><li>PHPDocumentor </li><ul><li>http://www.phpdoc.org/ </li></ul><li>Uses reflection
  72. 72. Comments for additional information
  73. 73. Add descriptions to the documentation </li></ul>
  74. 74. PHPDocumentor Comments 1 < ?php 2 3 class AttendeeList { 4 private $attendees ; 5 private $observers ; 6 7 /** 8 * Add an attendee to the list 9 * 10 * @param integer $id Attendee identifier/array index 11 * @param string $name Full name of the attendee 12 * @access public 13 * @return boolean If attendee was successfully added 14 */ 15 public function addAttendee ( $id , $name ) { 16 $this -> attendees [ $id ] = $name ; 17 $this -> notify (); 18 } 19 20 }
  75. 75. Beyond API Docs <ul><li>Tutorials
  76. 76. Installation instructions
  77. 77. Examples
  78. 78. FAQs
  79. 79. Forums
  80. 80. User-contributed </li></ul>
  81. 81. Today's Outline <ul><li>Software Development Lifecycle
  82. 82. Databases
  83. 83. Source Control
  84. 84. Documentation
  85. 85. Open Source </li></ul>
  86. 86. Other Topics <ul><li>System administration
  87. 87. Maintenance and bugs
  88. 88. Design patterns </li></ul>
  89. 89. Open Source
  90. 90. Open Source <ul><li>Free software </li><ul><li>Free as in beer
  91. 91. Free as in freedom </li></ul><li>Licensing </li><ul><li>BSD
  92. 92. GPL </li></ul><li>Avoid reinventing the wheel </li></ul>
  93. 93. Open Source <ul><li>Find excellent (free) tools
  94. 94. Build excellent (free) tools </li></ul>
  95. 95. The Local PHP Scene <ul><li>LeedsPHP http://leedsphp.org
  96. 96. PHPNW http://phpnw.org.uk
  97. 97. GeekUp http://geekup.org </li></ul>
  98. 98. The Global PHP Scene <ul><li>Everything happens on IRC </li><ul><li>try #phpc or #phpnw for starters </li></ul><li>Read http://phpdeveloper.org daily
  99. 99. Check out http://stackoverflow.com
  100. 100. Learn to help yourself! </li></ul>
  101. 101. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×