Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ninja Techniques: Tips, Tricks, & Tools for Bei...

neraath
August 15, 2012

Ninja Techniques: Tips, Tricks, & Tools for Being More Productive as a Developer

All developers have tools in their digital (and sometimes physical) belt to help them do their job. But staying on-top of the tools ecosystem is just as much a challenge as keeping up with the technology we actively use. In this session, you'll learn some of the newest tools, tips, and hacks from the developer and agilist ecosystem that have the power to make you even more productive and your life as a developer a whole lot more enjoyable. Do you have the skills and interest to become a coding ninja?

neraath

August 15, 2012
Tweet

More Decks by neraath

Other Decks in Programming

Transcript

  1. Me • Fightin’ Texas Aggie • PHP Developer since 2003

    • Agilist since 2007 • Co-organizer of BCSPHP • Senior Consultant at Improving Enterprises • [email protected] Tuesday, August 14, 12
  2. Twitter Promotion • @neraath • @dallasphp • #phpninja • #thisguyisawesome

    • #awesomesauce • #terrbilepresenter Tuesday, August 14, 12
  3. Twitter Promotion • @neraath • @dallasphp • #phpninja • #thisguyisawesome

    • #awesomesauce • #terrbilepresenter • #worstpresentation Tuesday, August 14, 12
  4. Agile, Microsoft, Open Technologies, UX Applied Training, Coaching, Mentoring Certified

    Consulting Rural Sourcing Recruiting Services Tuesday, August 14, 12
  5. Agenda • An agilist’s perspective on how to... • Be

    More Productive as a PHP Developer • Be More Productive as a General Developer • Be More Productive as an Individual Tuesday, August 14, 12
  6. Suppose We Need... • PHPUnit 2.4.1 • phpDocumentor 2.0.2 •

    PHPCodeSniffer 2.0.4 • Zend Framework 1.10 • Doctrine 2.1 • ... Tuesday, August 14, 12
  7. PEAR’s Pitfalls • System-wide dependency • Multiple projects; different version

    dependencies • Ensuring same versions across developer workstations / servers Tuesday, August 14, 12
  8. $> svn propedit svn:externals . library/Zend http://framework.zend.com/svn/framework/standard/branches/ test/library/Zend http://framework.zend.com/svn/framework/standard/bran test/library/phpcs

    http://pear.php.net/package/PHP_CodeSniffer/some/svn test/library/PHPUnit https://svn.github.com/sebastianbergmann/phpunit library/CustomLib http://internal.myco.com/svn/CustomLib/branches/... Tuesday, August 14, 12
  9. $> svn up apollo:evernote-2.x neraath$ svn up Fetching external item

    into 'library/Zend' U library/Zend/Version.php Updated external to revision 25030. Fetching external item into 'test/library/Zend' Updated external to revision 25030. Fetching external item into 'test/library/phpcs' Updated external to revision 350234. ... Tuesday, August 14, 12
  10. I will hunt you down and shoot you like a

    duck dog. Tuesday, August 14, 12
  11. apollo:qtfx neraath$ curl http://getcomposer.org/installer | php % Total % Received

    % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11038 0 11038 0 0 9958 0 --:--:-- 0:00:01 --:--:-- 21516 #!/usr/bin/env php All settings correct for using Composer Downloading... Composer successfully installed to: /Users/neraath/Development/qtfx/composer.phar Use it: php composer.phar Tuesday, August 14, 12
  12. apollo:qtfx neraath$ php composer.phar install Installing dependencies - Installing symfony/finder

    (dev-master) Cloning v2.1.0-RC1 - Installing symfony/yaml (dev-master) Cloning 6b3eb66a7c4495dcaa35a64dd93c8ba8c29f35d8 - Installing symfony/translation (dev-master) Cloning v2.1.0-RC1 ... - Installing behat/gherkin (v2.2.4) Downloading: 100% - Installing behat/behat (v2.4.3) Downloading: 100% symfony/event-dispatcher suggests installing symfony/http-kernel (dev- master) behat/behat suggests installing behat/symfony2-extension (for integration with Symfony2 web framework) behat/behat suggests installing behat/yii-extension (for integration with Yii web framework) behat/behat suggests installing behat/mink-extension (for integration with Mink testing framework) Writing lock file Generating autoload files Tuesday, August 14, 12
  13. What is TDD Good For? • Developers stating known assumptions

    up-front • Minimizing production code • Testing units of code • Automated suite of regression tests Tuesday, August 14, 12
  14. TDD’s Limitations • QA often don’t trust unit tests •

    Business + QA don’t understand unit tests • Lack of cohesive language to describe acceptance criteria Tuesday, August 14, 12
  15. • Tests written in Gerkhin • Given a precondition •

    When some action occurs Tuesday, August 14, 12
  16. • Tests written in Gerkhin • Given a precondition •

    When some action occurs • Then an outcome is achieved Tuesday, August 14, 12
  17. Feature: ls In order to see the directory structure As

    a UNIX user I need to be able to list the current director contents Scenario: List 2 files in a directory Given I am in directory “test” And I have a file named “foo” And I have a file named “bar” When I run “ls” Then I should get: “”” bar foo “”” Tuesday, August 14, 12
  18. Feature: registration In order to be able to use the

    system As a privileged user I need to be able to register for an account Scenario: Unmatched username and password Given I have a password “password” And I have a confirm password “password2” When I attempt to register Then I should get a validation error Tuesday, August 14, 12
  19. <?php // You can implement step definitions for undefined steps

    with these snippets: /** * @Given /^I have a password "([^"]*)"$/ */ public function iHaveAPassword($arg1) { throw new PendingException(); } /** * @Given /^I have a confirm password "([^"]*)"$/ */ public function iHaveAConfirmPassword($arg1) { throw new PendingException(); } /** * @When /^I attempt to register$/ */ public function iAttemptToRegister() { throw new PendingException(); } /** * @Then /^I should get a validation error$/ */ public function iShouldGetAValidationError() Tuesday, August 14, 12
  20. apollo:qtfx neraath$ bin/behat Feature: registration In order to be able

    to use the system As a privileged user I need to be able to register for an account Scenario: Unmatched username and password # features/registration.feature:6 Given I have a password "password" And I have a confirm password "password2" When I attempt to register Then I should get a validation error 1 scenario (1 undefined) 4 steps (4 undefined) 0m0.023s Tuesday, August 14, 12
  21. Other BDD Practices • Test behaviors - not units •Stop

    mocking/stubbing/faking! •You are supposed to be writing end-to-end tests •Plan, build, and automate your testing environments •Work with the business/QA to develop acceptance criteria Tuesday, August 14, 12
  22. Do you... • create automated documentation? • run unit tests

    with any regular occurrence? • rebuild/clean/update your database more than once a week? • repeat a lot of repetitive command-line tasks? Tuesday, August 14, 12
  23. phing • PHing Is Not GNU make • Like Apache

    Ant • Build Automation Tool Tuesday, August 14, 12
  24. phing Capabilities • Running PHPUnit or SimpleTest test suites •

    File Transformations • Filesystem Operations • SQL Execution • CVS/SVN/GIT Operations • Documentation Generation Tuesday, August 14, 12
  25. <?xml version="1.0"?> <project name="quicktate-api" description="Phing build file for the Quicktate

    API project" default="test"> <target name="setup" description="Creates the build directories."> <mkdir dir="./build" /> </target> <target name="clean" description="Cleans up the build directories."> <delete dir="./build" /> </target> <target name="test" depends="setup" description="Runs unit tests for the project."> <phpunit bootstrap="./test/bootstrap.php" haltonerror="true" haltonfailure="true"> <formatter type="plain" usefile="false"/> <batchtest> <fileset dir="test"> <include name="**/*Test*.php"/> </fileset> </batchtest> </phpunit> </target> </project> Tuesday, August 14, 12
  26. apollo:quicktate-api neraath$ phing setup Buildfile: /Users/neraath/Development/quicktate/quicktate-api/build.xml quicktate-api > setup: [mkdir]

    Created dir: /Users/neraath/Development/quicktate/quicktate-api/build BUILD FINISHED Total time: 0.0854 seconds Tuesday, August 14, 12
  27. apollo:quicktate-api neraath$ phing clean Buildfile: /Users/neraath/Development/quicktate/quicktate-api/build.xml quicktate-api > clean: [delete]

    Deleting directory /Users/neraath/Development/quicktate/quicktate-api/ build BUILD FINISHED Total time: 0.0855 seconds Tuesday, August 14, 12
  28. Use phing if you... • Have to perform any step

    besides checking out to get a web site running • Install/write setup data to the database • Look at dbdeploy or Doctrine::Migrations • Setup log files Tuesday, August 14, 12
  29. [dbdeploy] dbdeploy 3.0M2 [dbdeploy] Reading change scripts from directory /tmp/dbdeploy-3.0M2/example...

    [dbdeploy] Changes currently applied to database: [dbdeploy] (none) [dbdeploy] Scripts available: [dbdeploy] 1, 2 [dbdeploy] To be applied: [dbdeploy] 1, 2 [dbdeploy] Applying #1: 001_create_table.sql... [dbdeploy] Applying #2: 002_insert_data.sql... dbdeploy Tuesday, August 14, 12
  30. neraath@qtapp1:/usr/local/lib/quicktate-evernote$ sudo ./bin/doctrine migrations:status -- configuration=config/migrations.yml == Configuration >> Name:

    Quicktate Doctrine Migrations >> Database Driver: pdo_mysql >> Database Name: quicktate >> Configuration Source: /usr/local/lib/quicktate-evernote/config/migrations.yml >> Version Table Name: doctrine_migration_versions >> Migrations Namespace: Quicktate\Migrations >> Migrations Directory: /usr/local/lib/quicktate-evernote/db/migrations >> Current Version: 2012-07-15 14:00:00 (20120715140000) >> Latest Version: 2012-07-15 14:00:00 (20120715140000) >> Executed Migrations: 13 >> Available Migrations: 13 >> New Migrations: 0 Doctrine::Migrations Tuesday, August 14, 12
  31. If it’s difficult or painful, do it more often. If

    it’s difficult or painful, Tuesday, August 14, 12
  32. Incomplete Features • Sometimes a feature is just too big

    • Incomplete features across releases Tuesday, August 14, 12
  33. Incomplete Features • Sometimes a feature is just too big

    • Incomplete features across releases • Ship it anyways! Tuesday, August 14, 12
  34. Incomplete Features • Sometimes a feature is just too big

    • Incomplete features across releases • Ship it anyways! • Beware the Beta Tuesday, August 14, 12
  35. Incomplete Features • Sometimes a feature is just too big

    • Incomplete features across releases • Ship it anyways! • Beware the Beta • Solution: Feature Toggles Tuesday, August 14, 12
  36. Continued Learning • Blogs • User Groups • TechFests •

    Hackathons • Conferences Tuesday, August 14, 12
  37. Pomodoro • Francesco Cirillo • Time Management Technique • Minimizing

    Distractions: Internal & External Tuesday, August 14, 12
  38. Internal Distractions • Reddit/Facebook/Twitter • Creating a Shopping List •

    What to get for lunch • Remembering to talk to boss after lunch • Remembering to grab a beer after the talk • Need to do X Tuesday, August 14, 12
  39. External Distractions • E-Mail & IM Communication • Phone Calls

    • Co-workers stopping by to “chat” • Impromptu Meetings Tuesday, August 14, 12
  40. Pomodoro Technique • 25 Minutes to Work on a single

    Task • 5 Minute Break • Repeat 4 times, then take longer break Tuesday, August 14, 12
  41. Planning and Reflecting • Plan top 3 priorities for the

    day • Write them down • As you complete them, check them off • Reflect at the end of the day Tuesday, August 14, 12
  42. Takeaways • Automate your life • Learn the power of

    your tools • Continue learning from the community • Start focusing - you’ll feel (and be) more successful Tuesday, August 14, 12