b-s-t easy as 1-2-3

33
Best Practices, Standards & Tools/Tips to make your life simpler B-S-T easy as 1-2-3 Sunday, September 27, 2009

Upload: chris-cornutt

Post on 18-May-2015

970 views

Category:

Technology


3 download

DESCRIPTION

B-S-T Easy as 1-2-3 (CodeWorks '09)

TRANSCRIPT

Page 1: B-S-T Easy as 1-2-3

Best Practices, Standards & Tools/Tips to make your life simpler

B-S-Teasy as1-2-3

Sunday, September 27, 2009

Page 2: B-S-T Easy as 1-2-3

What’s the Point?

Good development is good, but

better development kicks ass.

If it can be done easier and better

with less effort - why not?

Sunday, September 27, 2009

Page 3: B-S-T Easy as 1-2-3

Best Practices

Sunday, September 27, 2009

Page 4: B-S-T Easy as 1-2-3

Best PracticesA Best Practice is a technique, method, process, activity, incentive or reward that is believed to be more effective at delivering a particular outcome than any other technique, method, process, etc. The idea is that with proper processes, checks, and testing, a desired outcome can be delivered with fewer problems and unforeseen complications. Best practices can also be defined as the most efficient (least amount of effort) and effective (best results) way of accomplishing a task, based on repeatable procedures that have proven themselves over time for large numbers of people. Wikipedia: http://en.wikipedia.org/wiki/Best_practice

Sunday, September 27, 2009

Page 5: B-S-T Easy as 1-2-3

Sunday, September 27, 2009

Page 6: B-S-T Easy as 1-2-3

Best Practices(the best part)

By definition, best practices are what any group of developers and professionals have decided work best for any given situation. This means they’re opinions that have been confirmed by others, but it doesn’t mean that they’re law.

Any developer can suggest a new practice at any time. Every developer has their own speciality. Find your niche and suggest away!

Sunday, September 27, 2009

Page 7: B-S-T Easy as 1-2-3

Best Practices : What- Not just about PHP. Think bigger.

- Best makes better

- Biggest bang for the buck

- Defining them is hard (no, really)

Sunday, September 27, 2009

Page 8: B-S-T Easy as 1-2-3

Best Practices : Good- Hit the ground running

- Helps you consider the important things

- Defines a set of “rules” you can use

- Keeps you current

Sunday, September 27, 2009

Page 9: B-S-T Easy as 1-2-3

Best Practices : Bad- Do more harm than good

- Understand! or don’t implement

- “Old wine in new bottles”

- Best? or Just Good Enough?

- Skip to the good parts

- Consider the future

Sunday, September 27, 2009

Page 10: B-S-T Easy as 1-2-3

Best Practices : Consider- How to benchmark the results

- Have the knowledge in-house

- Remember to innovate!

Sunday, September 27, 2009

Page 11: B-S-T Easy as 1-2-3

Best Practices : PHP

- Unit testing

- Documentation

- Standardized Deployment

- Design patterns

- Source control

- Well-structured

- Integration tests

- Benchmarking

- Coding standards

Sunday, September 27, 2009

Page 12: B-S-T Easy as 1-2-3

StandardsSunday, September 27, 2009

Page 13: B-S-T Easy as 1-2-3

StandardsA technical standard is an established norm or requirement. It is usually a formal document that establishes uniform engineering or technical criteria, methods, processes and practices. A technical standard may be developed privately or unilaterally, for example by a corporation, regulatory body, military, etc. Standards can also be developed by groups such as trade unions, and trade associations.

Wikipedia: http://en.wikipedia.org/wiki/Standards

Sunday, September 27, 2009

Page 14: B-S-T Easy as 1-2-3

Standards : What- Not just about PHP. Think bigger.

- Proven excellence

- Regularly used by a certain group or project

Sunday, September 27, 2009

Page 15: B-S-T Easy as 1-2-3

Standards : What- Naming conventions

- Variable definitions

- Commenting styles (like DocBlock)

- Use of external libraries

- How things fit together

Sunday, September 27, 2009

Page 16: B-S-T Easy as 1-2-3

Standards : Good- Levels the playing field

- Easier to get in on the game

- Can reduce the small issues

- Public standards make for easier integration

Sunday, September 27, 2009

Page 17: B-S-T Easy as 1-2-3

Standards : Bad- Where’s the quality control?

- Too strict?

- Could stifle creativity

- Poor implementation

Sunday, September 27, 2009

Page 18: B-S-T Easy as 1-2-3

Standards : Consider- Will it work for your group?

- Does the team size warrant the effort?

- Will the team accept it?

- Think wide, then narrow

Sunday, September 27, 2009

Page 19: B-S-T Easy as 1-2-3

Are they required for success?

Hint: no.

Sunday, September 27, 2009

Page 20: B-S-T Easy as 1-2-3

Tools &TipsSunday, September 27, 2009

Page 21: B-S-T Easy as 1-2-3

Tools & Tips

Tools you can use to help encourage, enforce, plan out, etc.

Helpful hints and tips on their implementation

Sunday, September 27, 2009

Page 22: B-S-T Easy as 1-2-3

Tools & Tips

- PHP_CodeSniffer (PEAR)

- Zend, PEAR, PHPCS, Squiz & MySource

Standards

Sunday, September 27, 2009

Page 23: B-S-T Easy as 1-2-3

Tools & Tips

$ phpcs /path/to/code/myfile.php

FILE: /path/to/code/myfile.php--------------------------------------------------------------------------------FOUND 5 ERROR(S) AND 1 WARNING(S) AFFECTING 5 LINE(S)--------------------------------------------------------------------------------  2 | ERROR   | Missing file doc comment 20 | ERROR   | PHP keywords must be lowercase; expected "false" but found    |         | "FALSE" 47 | ERROR   | Line not indented correctly; expected 4 spaces but found 1 47 | WARNING | Equals sign not aligned with surrounding assignments 51 | ERROR   | Missing function doc comment 88 | ERROR   | Line not indented correctly; expected 9 spaces but found 6--------------------------------------------------------------------------------

StandardsExample PHP_CodeSniffer Output

Sunday, September 27, 2009

Page 24: B-S-T Easy as 1-2-3

Tools & Tips

- PHP_CodeSniffer (PEAR)

- Zend, PEAR, PHPCS, Squiz & MySource

- Other Documentation source (like wiki/shared resource)

Standards

Sunday, September 27, 2009

Page 25: B-S-T Easy as 1-2-3

Tools & Tips

- PHPUnit

Testing

phpunit.de

<?phpclass MySimpleClassTest extends PHPUnit_Framework_TestCase {

private $_cvar = ‘test’;function testMyExample(){

$val=‘test’;$this->assertEquals($val,$this->_cvar);

}}?>

Sunday, September 27, 2009

Page 26: B-S-T Easy as 1-2-3

Tools & Tips

- PHPUnit

- SimpleTest

Testing

phpunit.de

simpletest.org

<?phpclass MySimpleClassTest extends UnitTestCase {

private $_cvar = ‘test’;function testMyExample(){

$val=‘test’;$this->assertEqual($val,$this->_cvar);

}}?>

Sunday, September 27, 2009

Page 27: B-S-T Easy as 1-2-3

Tools & Tips

- PHPUnit

- SimpleTest

- Selenium

- WebTest

Testing

phpunit.de

simpletest.org

seleniumhq.org

webtest.canoo.com

Sunday, September 27, 2009

Page 28: B-S-T Easy as 1-2-3

Tools & Tips

- PHPUnit

- SimpleTest

- Selenium

- WebTest

- ab & siege

Testing

phpunit.de

simpletest.org

seleniumhq.org

webtest.canoo.com

joedog.org

Sunday, September 27, 2009

Page 29: B-S-T Easy as 1-2-3

Tools & Tips

- Capistrano

- Ant

- Phing

Deployment

capify.org

ant.apache.org

phing.info

Sunday, September 27, 2009

Page 30: B-S-T Easy as 1-2-3

Tools & TipsDeployment - Phing

<?xml version=”1.0”><project name=”deploy_me” default=”main”>

<property name=”version” value=”1.0” />

<target name=”unittest”><phpunit>

<batchtest><fileset dir=”/www/mysite/tests”>

<include name=”**/*Test*.php” /></fileset>

</batchtest></phpunit>

</target><target name=”phpdoc” depends=”unittest”>

<phpdoc title=”MySite Documentation” destdir=”/www/mysite/docs” output=”HTML:Smarty:PHP”><fileset dir=”/www/mysite/docroot”>

<include name=”**/*.php” /></fileset>

</phpdoc></target><target name=”lintme” depends=”phpdoc”>

<phplint><fileset dir=”/www/mysite/docroot”>

<include name=”**/*.php” /></fileset>

</phplint></target><target name=”standardsplz” depends=”lintme”>

<phpcodesniffer standard=”PEAR” format=”summary” file=”/www/mysite/docroot” allowedFileExtensions=”php php5 inc” />

</target><target name=”main” depends=”standardsplz”></target>

</project>

Sunday, September 27, 2009

Page 31: B-S-T Easy as 1-2-3

Tools & Tips

- Capistrano

- Ant

- Phing

- CruiseControl

- phpUnderControl

Deployment

capify.org

ant.apache.org

phing.info

cruisecontrol.sourceforge.net

phpundercontrol.org

Sunday, September 27, 2009

Page 32: B-S-T Easy as 1-2-3

Work SmarterFasterBetter

...and don’t forget to share!

(best?)

Sunday, September 27, 2009

Page 33: B-S-T Easy as 1-2-3

Thats It!

Chris [email protected]

Rate this talk at: http://joind.in/719 Photo Credits:

easy button (Jason Gulledge)http://www.flickr.com/photos/ramdac/373881476/

red structure: strutturahttp://www.flickr.com/photos/cane_rosso/1748958423/sizes/o/

Dreaming of Diamonds (Swamibu)http://www.flickr.com/photos/swamibu/1182138940/

Contact, Credits

@enygma@phpdeveloper

@joindin@dallasphp http://DallasPHP.org

Sunday, September 27, 2009