119
ThoughtWorks ThoughtWorks NEAL FORD software architect / meme wrangler ThoughtWorks [email protected] 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com memeagora.blogspot.com the productive programer: mechanics

the productive programer: mechanics

Embed Size (px)

Citation preview

Page 1: the productive programer: mechanics

ThoughtWorksThoughtWorks

NEAL FORD software architect / meme wrangler

ThoughtWorks

[email protected] 3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com

www.thoughtworks.com

memeagora.blogspot.com

the productive programer: mechanics

Page 2: the productive programer: mechanics

ThoughtWorks

Page 3: the productive programer: mechanics

where did this topic come from?

?

Page 4: the productive programer: mechanics

where did this topic come from?

Page 5: the productive programer: mechanics

where did this topic come from?

Page 6: the productive programer: mechanics

automationkilling distractions

canonicalityapplying the dry principle

getting your computer to work harder

focusdoing stuff faster

acceleration

what i cover:

Page 7: the productive programer: mechanics

acceleration

Page 8: the productive programer: mechanics

typing is faster than navigation

Page 9: the productive programer: mechanics

firefox

windows explorer address bar (alt-d)

finder (apple-shift-g)

number-fox plugin

/ searching

o/s accelerators

Page 10: the productive programer: mechanics

leopard smart help X

Page 11: the productive programer: mechanics

iClip ($$)

why do operating systems have only 1 clipboard with 1 entry????

clcl

jump cut

clipboards

X

Page 12: the productive programer: mechanics

context switching eats time

Page 13: the productive programer: mechanics

pushd pushes a directory on the stack

popd pops it back off

there and back

C:\temp>pushd \MyDocuments\Documents\dev\haskell

C:\MyDocuments\Documents\dev\haskell>dir02/13/2006 12:12 AM <DIR> .02/13/2006 12:12 AM <DIR> ..02/13/2006 12:12 AM <DIR> nfjs_functionallangs_haskell 0 File(s) 0 bytes 3 Dir(s) 11,743,178,752 bytes free

C:\MyDocuments\Documents\dev\haskell>popd

Page 14: the productive programer: mechanics

command prompt here power toy

graphical explorers better for some things....

...command line better for others

bash here (cygwin)

command prompts

Page 15: the productive programer: mechanics

command prompt explorer bar

Page 16: the productive programer: mechanics

path finder X

Page 17: the productive programer: mechanics

how many of you have written an application for heads-down data entry

personnel?

Page 18: the productive programer: mechanics

when coding, always prefer keyboard to mouse

Page 19: the productive programer: mechanics

pair programmer

make yourself use the shortcut even if you’ve gotten there another way

have someone/something pester you about it

key promoter for eclipse (mousefeed)

key promoter plug-in for intellij

learning shortcuts

Page 20: the productive programer: mechanics

repeat them to yourself

flash cards

learning shortcuts

Page 21: the productive programer: mechanics

all our hierarchies are too deep: file system packages

Page 22: the productive programer: mechanics

goto class

Page 23: the productive programer: mechanics

goto class: pattern of capital letters

Page 24: the productive programer: mechanics

introduce variable

Page 25: the productive programer: mechanics

escalating selection

Page 26: the productive programer: mechanics

some choice shortcuts

intelliJ eclipse

goto class ctrl-n ctrl-shift-t

introduce variable ctrl-alt-v alt-shift-lescalating selection ctrl-w alt-shift-uprecently edited files ctrl-e n/a (ctrl-e)symbol list alt-ctrl-shift-n ctrl-oincremental search alt-f3 ctrl-j

Page 27: the productive programer: mechanics

learn the language of your template engine

all major ide’s and coding text editors

parameter substitution, default values, repeating values

bash for textmate/e editor

velocity in intellij

live templates

Page 28: the productive programer: mechanics

intellij

templates

Page 29: the productive programer: mechanics

every time you type something for the 3rd time,

templatize it

Page 30: the productive programer: mechanics

textexpander

live templates at the o/s level

auto-hot key

typinator

key macro tools

X

Page 31: the productive programer: mechanics

don’t type the same commands over and over

Page 32: the productive programer: mechanics

focus

Page 33: the productive programer: mechanics

...sitting immediately in front of you

get a comfortable chair!

dual monitors...

good keyboard

administrator privilege for the o/s

simple stuff

Page 34: the productive programer: mechanics

how many people here work in...

modern office environments are terrible for knowledge workers

too much out of context noise

insidious distractions

Page 35: the productive programer: mechanics

war rooms

Page 36: the productive programer: mechanics

in flow, michael csikszentmihalyi describes flow state

in the humane interface, jef raskin describes locus of attention

anything that happens outside your locus of attention breaks flow

time disappears

total concentration

locus of attention

Page 37: the productive programer: mechanics
Page 38: the productive programer: mechanics

killing balloon tips

Page 39: the productive programer: mechanics

automatically makes your background dark after a set time

jedi concentrate

doodim

screen dimmers

X

Page 40: the productive programer: mechanics

the higher the level of concentration, the denser

the ideas

Page 41: the productive programer: mechanics

turn off instant messaging

turn off notifications

don’t keep email open

create office “quiet time”

put on headphones

the easy stuff

Page 42: the productive programer: mechanics

focus techniques

Page 43: the productive programer: mechanics

package/namespace

all developer hierarchies are too deep

file system

what worked well with 20 mb hard drives fails with 200 gb

documentation

search > navigation

Page 44: the productive programer: mechanics

google desktop search

built into modern operating systems

retro-fittable in older ones

larry’s “any text file” indexer

desktop search

Page 45: the productive programer: mechanics

replace file hierarchy navigation with search

Page 46: the productive programer: mechanics

grep searchs for strings from input or files

from *-nix & cygwin

find searches for files within a hierarchy

find + grep

Page 47: the productive programer: mechanics

from the current directory

matching files named *.java

pipe through xargs

grep with filenames & line numbers

matching this text

Page 48: the productive programer: mechanics

chain together conditions

execute the following onall matched files

placeholder for file name

terminatethe execcommand

Page 49: the productive programer: mechanics
Page 50: the productive programer: mechanics

use “hard target” searches to query your code base

Page 51: the productive programer: mechanics

what find + grep can’t provide

Page 52: the productive programer: mechanics

rooted view == project explorer

specialized explorer view

especially good for directory-based version control

C:\WINDOWS\explorer.exe /e,/root,c:\work\project

create a shortcut:

rooted views

Page 53: the productive programer: mechanics
Page 54: the productive programer: mechanics
Page 55: the productive programer: mechanics

virtual desktop manager power toy

virtual desktops allow you multiple isolated environments

bind applications to desktops

spaces (in leopard)

virtue desktops (in tiger)

use virtual desktops

X

Page 56: the productive programer: mechanics
Page 57: the productive programer: mechanics

canonicality

Page 58: the productive programer: mechanics

DRY says that every piece of system knowledge should have one authoritative, unambiguous representation. Every piece of knowledge in the development of something should have a

single representation. A system's knowledge is far broader than just its code. It refers to database schemas, test plans, the build

system, even documentation. the pragmatic programmer - andy hunt, dave thomas

Page 59: the productive programer: mechanics

decide on the canonical representation

object-relational mapping is one of the most common dry violations

database schema + xml configuration + pojo > 1

generate the others

dry o/r

Page 60: the productive programer: mechanics

the scenario

DDL

<xml>

<entity>

...

</entity>

</xml>

class Person {

int id;

double salary;

. . .

}

where’s the information?

Page 61: the productive programer: mechanics

canonical representation

DDL

<xml>

<entity>

...

</entity>

</xml>

class Person {

int id;

double salary;

. . .

}

Page 62: the productive programer: mechanics

the target

Page 63: the productive programer: mechanics

build event sql map

Page 64: the productive programer: mechanics
Page 65: the productive programer: mechanics
Page 66: the productive programer: mechanics

generated sql map

Page 67: the productive programer: mechanics

step 2: class builder

Page 68: the productive programer: mechanics
Page 69: the productive programer: mechanics
Page 70: the productive programer: mechanics
Page 71: the productive programer: mechanics
Page 72: the productive programer: mechanics

canonical representation

DDL

<xml>

<entity>

...

</entity>

</xml>

class Person {

int id;

double salary;

. . .

}

Page 73: the productive programer: mechanics

dry documentation

Page 74: the productive programer: mechanics

dry diagrams

Page 75: the productive programer: mechanics

open source schema diagrammer

the requirement: entity-relationship diagrams for each iteration

schemaspy

generates acceptable html

written in java

dry schemas

Page 76: the productive programer: mechanics

dry schemas

Page 77: the productive programer: mechanics

automation

Page 78: the productive programer: mechanics

version control (!)

one-command build

continuous integration

documentation

obvious automatables

Page 79: the productive programer: mechanics

don’t build what you don’t have to build

Page 80: the productive programer: mechanics

live cd or ubuntu installation

open source project from ThoughtWorks

infrastructure in a box

buildix

Page 81: the productive programer: mechanics

trac

subversion

cruisecontrol

mingle

buildix parts

Page 82: the productive programer: mechanics

“A project dedicated to making code metrics so widely understood, valuable, and simple that their use becomes ubiquitous, thus raising the quality of software across

the industry.”

Page 83: the productive programer: mechanics

jdepend

code coverage with emma1-line change to switch to cobertura

checkstyle1-line switch for custom rule sets

volatility

javancss

panopticode parts

Page 84: the productive programer: mechanics

panopticode reports

code duplication using simian

panopticode aggregator

treemaps

panopticode parts

Page 85: the productive programer: mechanics

code coverage tree map

Page 86: the productive programer: mechanics

version database schema changes along with code

migrations for the rest of the world

jolt-award winner open source from ThoughtWorks london

builds delta scripts for you

dbDeploy

Page 87: the productive programer: mechanics

dbDeploy compares delta with patch table

someone (dba) creates a sql baseline

developers create delta scripts for each change

invoked from ant’s sql task

generates change scripts

using dbDeploy

Page 88: the productive programer: mechanics

use migrations to manage database schema changes

Page 89: the productive programer: mechanics

subverting other tools

Page 90: the productive programer: mechanics

allows you to automate debugging “wizard”-style web applications

open source tool for user acceptance testing of web applications

includes a side-project called selenium ide

...but it never is!

you always think “this is the last time”...

selenium

Page 91: the productive programer: mechanics
Page 92: the productive programer: mechanics

selenium defines an interaction api for web applications

record your interaction the 1st time you walk through the page

literally cuts hours off debugging time

have your q/a department record bug discoveries

automated interaction

Page 93: the productive programer: mechanics

don’t spend time doing by hand what you can automate

Page 94: the productive programer: mechanics

build your own tools

Page 95: the productive programer: mechanics

build shims & jigs

you almost never do anything just once

work like a craftsman, not a laborer

...but you build assets

building a tool takes a little longer than brute force...

Page 96: the productive programer: mechanics

adding new files to subversion repository

tortoise (on windows), but with limits

bash-fu

Page 97: the productive programer: mechanics

svnAddNewsvn st | grep '^\?' | tr '^\?' ' ' | sed 's/ [ ]*//' | sed 's/[ ]/\\ /g' | xargs svn add

svn st get svn status (new files start with “?”)

grep '^\?' find all new files

tr '^\?' ' ' translate the “?” into a space

sed 's/[ ]*//' substitute spaces to nothing

sed 's/[ ]/\\ /g' escape embedded spaces

xargs svn add pipe the improved arguments into svn

Page 98: the productive programer: mechanics

by hand?!?

the problem: 2 gb of log files / week

need to know the count of each exception type

automate with a bash script

more bash-fu

Page 99: the productive programer: mechanics

get counts of each exception

get all exception types from log file sort them

get unique list

Page 100: the productive programer: mechanics

windows scripting host

Page 101: the productive programer: mechanics

pipe properties from 1 command to another

powerful replacement for windows scripting host

uses objects the way *-nix uses plain text

windows power shell

Page 102: the productive programer: mechanics

comparisonsbash

wps

bash

wps

Page 103: the productive programer: mechanics

use .net types within power shell scripts

implemented with .net

Page 104: the productive programer: mechanics

cmdletsGet-Command Retrieves a list of all available cmdlets.

Get-Help Displays help information about cmdlets and concepts.

Get-WMIObject Retrieves management information by using WMI.

Get-EventLog Retrieves Windows event logs.

Get-Process Retrieves a single or list of active processes.

Get-Service Retrieves a Windows service.

Get-Content Reads in text files, treating each line as a child object.

Add-Content Appends content to a text file.

Copy-Item Copies an item

Get-Acl Retrieves access control lists (ACLs).

Page 105: the productive programer: mechanics

.net coupled to every nook & cranny in windows

windows power shell implemented in .net

take advantage of .net types and libraries

won’t have windows power shell!

“headless” longhorn arriving rsn

just one thing...

Page 106: the productive programer: mechanics

automating com

Page 107: the productive programer: mechanics

use a real language for scripting

examples in lots of different languages/tools

which one do I use for this problem?

scripting rationale

Page 108: the productive programer: mechanics

“we can do it by hand in 10 minutes...”

the problem: split a 38,000 line sql file into 1000 line chunks

each chunk must be syntactically correct

after 50 minutes:

automate instead

sql splitter

Page 109: the productive programer: mechanics
Page 110: the productive programer: mechanics

it “accidentally” became an important part of our project

it took us 5 times longer to automate it

we’ve had to do it numerous times since

...so that we could write unit tests

using a real language allowed us to refactor it...

time spent automating

Page 111: the productive programer: mechanics
Page 112: the productive programer: mechanics

if you start by treating it as a 1st class problem, you’ll build better solutions

allow throw-aways to grow into assets

allows unit testing, refactoring, ide support

using real languages

Page 113: the productive programer: mechanics

squanders focus

solving problems by hand makes you dumber

steals concentration

figure out clever ways to solve problems

automating makes you smarter

time savings

Page 114: the productive programer: mechanics

justifying automation

Page 115: the productive programer: mechanics

decide if you want to go forward

set a reasonable time to see if it’s possible

evaluate at the end of the box

or abandon the effort

or create another time box

timebox

Page 116: the productive programer: mechanics

automation is about

how long does it take now X # of times we must do it?

what are the consequences of doing it wrong 1 time?

risk mitigation

time savings

analyze the r.o.i.

Page 117: the productive programer: mechanics

don’t shave yaks!

Page 118: the productive programer: mechanics

ThoughtWorks

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.

http://creativecommons.org/licenses/by-nc-sa/2.5/

questions?

please fill out the session evaluationsslides & samples available at nealford.com

NEAL FORD software architect / meme wrangler

ThoughtWorks

[email protected] 3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com

www.thoughtworks.com

memeagora.blogspot.com

Page 119: the productive programer: mechanics

resources

ThoughtWorks

© 2008, Neal Ford

Published by O’Reilly Media

The Productive Programmer

Photos by Candy Ford

ISBN: 978-0-596-51978-0