cowboy coding to professional developer

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

Upload: andy-brudtkuhl

Post on 04-Aug-2015

68 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Cowboy Coding to Professional Developer

From Cowboy Coding to Professional Developer

Andy Brudtkuhl @abrudtkuhl

YouMetAndy.com/wckc

Page 2: Cowboy Coding to Professional Developer

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

Page 3: Cowboy Coding to Professional Developer

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

What makes a better developer?

Page 5: Cowboy Coding to Professional Developer

Be pragmatic.

Page 6: Cowboy Coding to Professional Developer

Be empathetic. (this is not easy)

Page 7: Cowboy Coding to Professional Developer
Page 8: Cowboy Coding to Professional Developer

Use standards. (please)

Page 9: Cowboy Coding to Professional Developer

Tools Don’t Matter. Tools Mean Everything

Page 10: Cowboy Coding to Professional Developer

Be a good teammate.

Page 11: Cowboy Coding to Professional Developer

Avoid Shiny Objects

Page 12: Cowboy Coding to Professional Developer

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

Page 13: Cowboy Coding to Professional Developer

Automate your busy work.

Page 14: Cowboy Coding to Professional Developer

Test your software (because someone else will)

Page 15: Cowboy Coding to Professional Developer

Don’t Repeat Yourself.

Page 16: Cowboy Coding to Professional Developer
Page 17: Cowboy Coding to Professional Developer

Setup a local dev environment.

Page 18: Cowboy Coding to Professional Developer

Local Dev Environment

• MAMP Pro

• Desktop Server

• VVV

Page 19: Cowboy Coding to Professional Developer

Use version control.

Page 20: Cowboy Coding to Professional Developer

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

Sync your data.

Page 22: Cowboy Coding to Professional Developer

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

Deploy with sanity.

Page 24: Cowboy Coding to Professional Developer

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

Being A Better WordPress Developer

Tips and tools to be a better WordPress developer

Page 26: Cowboy Coding to Professional Developer

define( 'WP_DEBUG', true );

Page 27: Cowboy Coding to Professional Developer

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

the loop.

Page 29: Cowboy Coding to Professional Developer

Follow WordPress Standards

• Read the Codex

• Follow WordPress developer standards for Themes, Plugins, and Core Contribution

Page 30: Cowboy Coding to Professional Developer

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

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

Use Template Parts

• Create reusable template parts

• Build reusable loops

• Reduce and Reuse code

Page 33: Cowboy Coding to Professional Developer

Validate, Sanitize, Escape

• Validate = check user input

• Sanitize = clean user input

• Escape = securing user generated output

Page 34: Cowboy Coding to Professional Developer

Transients FTW

• Simple Caching

• Big Performance

• Store data you expect to expire

Page 35: Cowboy Coding to Professional Developer

Use Starter Templates

• WordPress Plugin Boilerplate

• Theme templates like sage, roots, _s

• GenerateWP.com

Page 36: Cowboy Coding to Professional Developer

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

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

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

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

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

Page 41: Cowboy Coding to Professional Developer

YouMetAndy.com/wckc @abrudtkuhl