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

Cowboy Coding to Professional Development

Cowboy Coding to Professional Development

WordCamp Kansas City 2015 Presentation on moving from cowboy coding to professional development.

Slide notes and links available at http://brudtkuhl.com/cowboy-coding-to-professional-developer-wckc-2015/

Andy Brudtkuhl

June 13, 2015
Tweet

More Decks by Andy Brudtkuhl

Other Decks in Programming

Transcript

  1. From Cowboy Coding to
    Professional Developer
    Andy Brudtkuhl
    @abrudtkuhl
    YouMetAndy.com/wckc

    View Slide

  2. What Is Cowboy Coding?
    … and why it is a necessary evil

    View Slide

  3. TL;DR
    Don’t code live on your production server. Use version control.
    Be nice, use standards, and avoid shiny object syndrome.

    View Slide

  4. What makes a better developer?

    View Slide

  5. Be pragmatic.

    View Slide

  6. Be empathetic.
    (this is not easy)

    View Slide

  7. View Slide

  8. Use standards.
    (please)

    View Slide

  9. Tools Don’t Matter.
    Tools Mean Everything

    View Slide

  10. Be a good teammate.

    View Slide

  11. Avoid Shiny Objects

    View Slide

  12. Be verbose.
    (comment your code, describe your commits)

    View Slide

  13. Automate your busy work.

    View Slide

  14. Test your software
    (because someone else will)

    View Slide

  15. Don’t Repeat Yourself.

    View Slide

  16. View Slide

  17. Setup a local dev
    environment.

    View Slide

  18. Local Dev Environment
    • MAMP Pro
    • Desktop Server
    • VVV

    View Slide

  19. Use version control.

    View Slide

  20. What goes in Git?
    • Entire Site
    • Single Plugins and Themes
    • Never commit your wp-config.php file
    • Google “Git Ignore WordPress” for an
    example .gitignore file

    View Slide

  21. Sync your data.

    View Slide

  22. WP DB Migrate Pro
    • Use WP DB Migrate Pro
    • Migrate Data
    • Push / Pull Sync Data
    • Use WP_CLI addon to automate

    View Slide

  23. Deploy with sanity.

    View Slide

  24. Deploy with sanity
    • Dev / Test / Production environments
    • Stop doing things manually
    • Use WP-DB-MIGRATE to move data
    • Use WP-Pusher to deploy updates (no FTP, yay!)
    • Use Git on your server
    • Capistrano or Chef

    View Slide

  25. Being A Better
    WordPress Developer
    Tips and tools to be a better WordPress developer

    View Slide

  26. define( 'WP_DEBUG', true );

    View Slide

  27. Separate Concerns
    • Use Plugins for functionality and Themes for
    design
    • Don’t abuse functions.php
    • Use functionality plugins

    View Slide

  28. the loop.

    View Slide

  29. Follow WordPress Standards
    • Read the Codex
    • Follow WordPress developer standards for
    Themes, Plugins, and Core Contribution

    View Slide

  30. Use Core Features
    • Theme Customizer
    • Settings API
    • Options API
    • Image Thumbnails
    • Menu System
    • Widgets, Shortcodes
    • Custom Post Types & Taxonomies

    View Slide

  31. Enqueue All The Things
    • Include scripts and stylesheets in Themes and
    Plugins by enqueuing them
    • NEVER include your own version of jQuery

    View Slide

  32. Use Template Parts
    • Create reusable template parts
    • Build reusable loops
    • Reduce and Reuse code

    View Slide

  33. Validate, Sanitize, Escape
    • Validate = check user input
    • Sanitize = clean user input
    • Escape = securing user generated output

    View Slide

  34. Transients FTW
    • Simple Caching
    • Big Performance
    • Store data you expect to expire

    View Slide

  35. Use Starter Templates
    • WordPress Plugin Boilerplate
    • Theme templates like sage, roots, _s
    • GenerateWP.com

    View Slide

  36. Know variable scope
    • Don’t define your own Globals
    • Use namespaces and classes to properly scope
    your variables

    View Slide

  37. WP-CLI
    • A WordPress command line interface
    • Setup, install, configure sites from your terminal
    • Easily create scripts to spin up new sites
    • Automate Database migrations
    • Schedule Database Migrations

    View Slide

  38. Manage Dependencies
    • Use plugin_exists( ‘my-plugin’ ), class_exists( ‘MyClass’ ),
    or function_exists( ‘my_awesome_function’ )
    • TGM Plugin Activation
    • Require / Recommend dependencies in your custom
    themes and plugins
    • Use composer
    • custom plugin or theme with third party dependencies

    View Slide

  39. My Workflow
    1. Grab a task (Jira or Trello)
    2. Pull latest version of project from Bitbucket
    3. Pull latest version of data from Staging / Production
    4. Code feature / fix bug
    5. Commit and push updated code with comment and
    link back to ticket in Jira/Trello
    6. Deploy with WP Pusher or Git

    View Slide

  40. My Tools
    • Editor: Atom.io
    • Local Dev: MAMP Pro
    • Terminal: iTerm
    • Source Control: Git with Bitbucket
    • Data Management: WP DB Migrate Pro
    • Deployment: WP Pusher
    • Site Management: InfiniteWP

    View Slide

  41. YouMetAndy.com/wckc
    @abrudtkuhl

    View Slide