cowboy coding to professional developer
TRANSCRIPT
![Page 1: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/1.jpg)
From Cowboy Coding to Professional Developer
Andy Brudtkuhl @abrudtkuhl
YouMetAndy.com/wckc
![Page 2: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/2.jpg)
What Is Cowboy Coding?… and why it is a necessary evil
![Page 3: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/3.jpg)
TL;DRDon’t code live on your production server. Use version control.
Be nice, use standards, and avoid shiny object syndrome.
![Page 4: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/4.jpg)
What makes a better developer?
![Page 5: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/5.jpg)
Be pragmatic.
![Page 6: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/6.jpg)
Be empathetic. (this is not easy)
![Page 7: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/7.jpg)
![Page 8: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/8.jpg)
Use standards. (please)
![Page 9: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/9.jpg)
Tools Don’t Matter. Tools Mean Everything
![Page 10: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/10.jpg)
Be a good teammate.
![Page 11: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/11.jpg)
Avoid Shiny Objects
![Page 12: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/12.jpg)
Be verbose. (comment your code, describe your commits)
![Page 13: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/13.jpg)
Automate your busy work.
![Page 14: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/14.jpg)
Test your software (because someone else will)
![Page 15: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/15.jpg)
Don’t Repeat Yourself.
![Page 16: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/16.jpg)
![Page 17: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/17.jpg)
Setup a local dev environment.
![Page 18: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/18.jpg)
Local Dev Environment
• MAMP Pro
• Desktop Server
• VVV
![Page 19: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/19.jpg)
Use version control.
![Page 20: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/20.jpg)
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
![Page 21: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/21.jpg)
Sync your data.
![Page 22: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/22.jpg)
WP DB Migrate Pro
• Use WP DB Migrate Pro
• Migrate Data
• Push / Pull Sync Data
• Use WP_CLI addon to automate
![Page 23: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/23.jpg)
Deploy with sanity.
![Page 24: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/24.jpg)
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
![Page 25: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/25.jpg)
Being A Better WordPress Developer
Tips and tools to be a better WordPress developer
![Page 26: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/26.jpg)
define( 'WP_DEBUG', true );
![Page 27: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/27.jpg)
Separate Concerns
• Use Plugins for functionality and Themes for design
• Don’t abuse functions.php
• Use functionality plugins
![Page 28: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/28.jpg)
the loop.
![Page 29: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/29.jpg)
Follow WordPress Standards
• Read the Codex
• Follow WordPress developer standards for Themes, Plugins, and Core Contribution
![Page 30: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/30.jpg)
Use Core Features• Theme Customizer
• Settings API
• Options API
• Image Thumbnails
• Menu System
• Widgets, Shortcodes
• Custom Post Types & Taxonomies
![Page 31: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/31.jpg)
Enqueue All The Things
• Include scripts and stylesheets in Themes and Plugins by enqueuing them
• NEVER include your own version of jQuery
![Page 32: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/32.jpg)
Use Template Parts
• Create reusable template parts
• Build reusable loops
• Reduce and Reuse code
![Page 33: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/33.jpg)
Validate, Sanitize, Escape
• Validate = check user input
• Sanitize = clean user input
• Escape = securing user generated output
![Page 34: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/34.jpg)
Transients FTW
• Simple Caching
• Big Performance
• Store data you expect to expire
![Page 35: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/35.jpg)
Use Starter Templates
• WordPress Plugin Boilerplate
• Theme templates like sage, roots, _s
• GenerateWP.com
![Page 36: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/36.jpg)
Know variable scope
• Don’t define your own Globals
• Use namespaces and classes to properly scope your variables
![Page 37: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/37.jpg)
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
![Page 38: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/38.jpg)
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
![Page 39: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/39.jpg)
My Workflow1. 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
![Page 40: Cowboy Coding to Professional Developer](https://reader030.vdocument.in/reader030/viewer/2022032503/55c0e303bb61eb596f8b459b/html5/thumbnails/40.jpg)
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