habits of a responsible programmer

71
Habits of a Responsible Programmer Anders Janmyr @andersjanmyr http://anders.janmyr.com

Upload: andersjanmyr

Post on 18-Jul-2015

387 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Habits of a Responsible Programmer

Habits of a Responsible Programmer

Anders Janmyr@andersjanmyr

http://anders.janmyr.com

Page 2: Habits of a Responsible Programmer

Outline

• Definitions

• Programming

• Project

• Life, the Universe and Everything

• Summary

Page 3: Habits of a Responsible Programmer

Definitions

Page 4: Habits of a Responsible Programmer

Habit

An acquired behavior pattern, regularly followed,

until it has become almost involuntary

— dictionary.com

Page 5: Habits of a Responsible Programmer

The Conscious BrainSequential and Slow

Page 6: Habits of a Responsible Programmer

The Unconscious BrainParallel and Fast

Page 7: Habits of a Responsible Programmer

Habits

Page 8: Habits of a Responsible Programmer

Creating Habits

Outsourcing to our

unconscious

Page 9: Habits of a Responsible Programmer

Responsible

Accountable for somethingwithin one's power or control

— dictionary.com

Page 10: Habits of a Responsible Programmer

Why Be Responsible?

Page 11: Habits of a Responsible Programmer

Programming

Page 12: Habits of a Responsible Programmer

TypingAnd as for this

non-college bullshit I got two words for that:learn to fuckin' type!

— Mr. Pink

Page 13: Habits of a Responsible Programmer

Write Clear Code

Page 14: Habits of a Responsible Programmer

Consistent

• Follow Conventions

• Constants: SCREAMING_SNAKE_CASE

• HTML Attributes: dash-er-ized

• API: Naming, Ordering, etc.

Page 15: Habits of a Responsible Programmer

Don’t Quick Fix

Page 16: Habits of a Responsible Programmer

Short Classes, Functions, Parameter Lists

Page 17: Habits of a Responsible Programmer

Short Classes, Functions, Parameter Lists

Page 18: Habits of a Responsible Programmer

Separate Commands from Queries

Page 19: Habits of a Responsible Programmer

Separate Commands from Queries

Page 20: Habits of a Responsible Programmer

External Dependencies

• Use as few as practical

• Learn it well

• Wrap them

Page 21: Habits of a Responsible Programmer

Refactor Mercilessly

• When understanding changes

• Prevents bugs and frustration

• Don’t ask for permission!

Page 22: Habits of a Responsible Programmer

Balance

Page 23: Habits of a Responsible Programmer

Prefer Explicit

ExplicitSpecific

ConcreteDirect

ImplicitGenericAbstractIndirect

function helloWorld() { console.log(‘Hello World’);}

function helloWorld() { hello(‘World’);}

function hello(thing) { var m = ‘Hello ’+ thing; console.log(m);}

Page 24: Habits of a Responsible Programmer

Learn Basic Techniques

• Iteration and Recursion

• Conditional Code

• Functions and Closures

• Classes, Objects, Immutability

Page 25: Habits of a Responsible Programmer

Simple vs. Easy

SimpleSingular

Does one thingIs made of one thing

EasyClose at hand

Familiar

Page 26: Habits of a Responsible Programmer

Learn Advanced Techniques

• Meta-objects and Reflection

• Monads and Continuations

• Events, Contracts, ...

• Actors, Message Queues, ...

Page 27: Habits of a Responsible Programmer

Testing

Page 28: Habits of a Responsible Programmer

The Scientific MethodTheory

Prediction

Experiment

Observation

Page 29: Habits of a Responsible Programmer

What to Unit Test?Query Command

Assertresult

Assert direct publicside e!ects

Ignore Expect to send

Incoming

Type

@sandimetz Apr 2013

Message

IgnoreSent to Self

Outgoing

Origin

Saturday, April 27, 13

Page 30: Habits of a Responsible Programmer

Documentation

Page 31: Habits of a Responsible Programmer

README

• Description

• Installation Instructions

• Usage Instructions

• Examples

• Pointers to more documentation

Page 32: Habits of a Responsible Programmer

An Overview

Page 33: Habits of a Responsible Programmer

System Overview

DrawingMap

DescriptionA few pages

ServersDatabases

External services

Page 34: Habits of a Responsible Programmer

Domain Overview

DrawingMap

DescriptionA few pages

Bounded ContextCore Objects

Main supporting domains

Page 35: Habits of a Responsible Programmer

CommentsASSUMPTION:

TODO:

As Few As Possible

WTF:

Anything else

Page 36: Habits of a Responsible Programmer

Tools

• The Editor

• The Version Control System

• The Command Line

• A scripting language

• Anything you use on a daily basis

Page 37: Habits of a Responsible Programmer

The Editor

Page 38: Habits of a Responsible Programmer

Version Control System

Page 39: Habits of a Responsible Programmer

CV, legacy

Page 40: Habits of a Responsible Programmer

CV, modern

Page 42: Habits of a Responsible Programmer

A Good Commit Message

Page 43: Habits of a Responsible Programmer

Command Line

sudo lsof -nPi | grep LISTEN |awk '{printf "%-20s%8s%20s\n",$1,$2,$9}'| sort | uniq

Page 44: Habits of a Responsible Programmer

Scripting

Page 45: Habits of a Responsible Programmer

What to script?Alias

DeploymentVerification

Code Generation

Watch scripts

Setup Machines

Editor Macros

Page 46: Habits of a Responsible Programmer

A bash function (≈alias)

Page 47: Habits of a Responsible Programmer

Deploy new Server

Page 48: Habits of a Responsible Programmer

Go away,or I will replace you with a very small shell script!

Page 49: Habits of a Responsible Programmer

Environments

Page 50: Habits of a Responsible Programmer

All Environments

• Setup with ONE command

• Scripts are continuously maintained

Page 51: Habits of a Responsible Programmer

Production

• All configuration, dependencies

• Optimized for speed

• Configured for monitoring

Page 52: Habits of a Responsible Programmer

Development

• As similar as possible to production

• Optimized for development speed

• Short feedback cycle

• Watchers, live reloading, auto testing

Page 53: Habits of a Responsible Programmer

Test

• Test Fixtures

• Mock services

• Recorded API interactions

Page 54: Habits of a Responsible Programmer

Project

Page 55: Habits of a Responsible Programmer

Compromise

Page 56: Habits of a Responsible Programmer

Critique

Page 57: Habits of a Responsible Programmer

Own It!

Page 58: Habits of a Responsible Programmer

Why? Why? Why?

Page 59: Habits of a Responsible Programmer

Estimation

Page 60: Habits of a Responsible Programmer

It is better to ask for

forgiveness than to ask for

permission!-- Grace Hopper

Page 61: Habits of a Responsible Programmer
Page 62: Habits of a Responsible Programmer

Flow

Page 63: Habits of a Responsible Programmer

Focus

Page 64: Habits of a Responsible Programmer
Page 65: Habits of a Responsible Programmer

Know what makes you happy!

Page 66: Habits of a Responsible Programmer

Silva’s 4 rules of happiness

1. If you like something, enjoy it!

2. If you don’t like something, avoid it!

3. If you don’t like something and can’t avoid it, change it!

4. If you can’t or choose not to avoid or change it, change your perception of it!

Page 67: Habits of a Responsible Programmer

Not Important Important

Not Urgent

Urgent

✖ ✔

Urgent ≠ Important

Page 68: Habits of a Responsible Programmer

Relax

Page 69: Habits of a Responsible Programmer

Summary

• Write clean code

• Test

• Script everything

• Learn your tools by heart

• Optimize for flow

Page 70: Habits of a Responsible Programmer

Proud!

Page 71: Habits of a Responsible Programmer

Habits of a Responsible Programmer

Anders Janmyr@andersjanmyr

[email protected]

References http://anders.janmyr.com