the productive programer: mechanics
-
Upload
elliando-dias -
Category
Technology
-
view
1.412 -
download
0
Transcript of the productive programer: mechanics
![Page 1: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/1.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/2.jpg)
ThoughtWorks
![Page 3: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/3.jpg)
where did this topic come from?
?
![Page 4: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/4.jpg)
where did this topic come from?
![Page 5: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/5.jpg)
where did this topic come from?
![Page 6: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/6.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/7.jpg)
acceleration
![Page 8: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/8.jpg)
typing is faster than navigation
![Page 9: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/9.jpg)
firefox
windows explorer address bar (alt-d)
finder (apple-shift-g)
number-fox plugin
/ searching
o/s accelerators
![Page 10: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/10.jpg)
leopard smart help X
![Page 11: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/11.jpg)
iClip ($$)
why do operating systems have only 1 clipboard with 1 entry????
clcl
jump cut
clipboards
X
![Page 12: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/12.jpg)
context switching eats time
![Page 13: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/13.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/14.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/15.jpg)
command prompt explorer bar
![Page 16: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/16.jpg)
path finder X
![Page 17: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/17.jpg)
how many of you have written an application for heads-down data entry
personnel?
![Page 18: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/18.jpg)
when coding, always prefer keyboard to mouse
![Page 19: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/19.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/20.jpg)
repeat them to yourself
flash cards
learning shortcuts
![Page 21: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/21.jpg)
all our hierarchies are too deep: file system packages
![Page 22: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/22.jpg)
goto class
![Page 23: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/23.jpg)
goto class: pattern of capital letters
![Page 24: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/24.jpg)
introduce variable
![Page 25: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/25.jpg)
escalating selection
![Page 26: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/26.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/27.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/28.jpg)
intellij
templates
![Page 29: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/29.jpg)
every time you type something for the 3rd time,
templatize it
![Page 30: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/30.jpg)
textexpander
live templates at the o/s level
auto-hot key
typinator
key macro tools
X
![Page 31: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/31.jpg)
don’t type the same commands over and over
![Page 32: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/32.jpg)
focus
![Page 33: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/33.jpg)
...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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/34.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/35.jpg)
war rooms
![Page 36: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/36.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/37.jpg)
![Page 38: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/38.jpg)
killing balloon tips
![Page 39: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/39.jpg)
automatically makes your background dark after a set time
jedi concentrate
doodim
screen dimmers
X
![Page 40: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/40.jpg)
the higher the level of concentration, the denser
the ideas
![Page 41: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/41.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/42.jpg)
focus techniques
![Page 43: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/43.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/44.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/45.jpg)
replace file hierarchy navigation with search
![Page 46: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/46.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/47.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/48.jpg)
chain together conditions
execute the following onall matched files
placeholder for file name
terminatethe execcommand
![Page 49: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/49.jpg)
![Page 50: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/50.jpg)
use “hard target” searches to query your code base
![Page 51: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/51.jpg)
what find + grep can’t provide
![Page 52: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/52.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/53.jpg)
![Page 54: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/54.jpg)
![Page 55: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/55.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/56.jpg)
![Page 57: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/57.jpg)
canonicality
![Page 58: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/58.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/59.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/60.jpg)
the scenario
DDL
<xml>
<entity>
...
</entity>
</xml>
class Person {
int id;
double salary;
. . .
}
where’s the information?
![Page 61: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/61.jpg)
canonical representation
DDL
<xml>
<entity>
...
</entity>
</xml>
class Person {
int id;
double salary;
. . .
}
![Page 62: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/62.jpg)
the target
![Page 63: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/63.jpg)
build event sql map
![Page 64: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/64.jpg)
![Page 65: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/65.jpg)
![Page 66: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/66.jpg)
generated sql map
![Page 67: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/67.jpg)
step 2: class builder
![Page 68: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/68.jpg)
![Page 69: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/69.jpg)
![Page 70: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/70.jpg)
![Page 71: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/71.jpg)
![Page 72: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/72.jpg)
canonical representation
DDL
<xml>
<entity>
...
</entity>
</xml>
class Person {
int id;
double salary;
. . .
}
![Page 73: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/73.jpg)
dry documentation
![Page 74: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/74.jpg)
dry diagrams
![Page 75: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/75.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/76.jpg)
dry schemas
![Page 77: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/77.jpg)
automation
![Page 78: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/78.jpg)
version control (!)
one-command build
continuous integration
documentation
obvious automatables
![Page 79: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/79.jpg)
don’t build what you don’t have to build
![Page 80: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/80.jpg)
live cd or ubuntu installation
open source project from ThoughtWorks
infrastructure in a box
buildix
![Page 81: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/81.jpg)
trac
subversion
cruisecontrol
mingle
buildix parts
![Page 82: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/82.jpg)
“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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/83.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/84.jpg)
panopticode reports
code duplication using simian
panopticode aggregator
treemaps
panopticode parts
![Page 85: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/85.jpg)
code coverage tree map
![Page 86: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/86.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/87.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/88.jpg)
use migrations to manage database schema changes
![Page 89: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/89.jpg)
subverting other tools
![Page 90: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/90.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/91.jpg)
![Page 92: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/92.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/93.jpg)
don’t spend time doing by hand what you can automate
![Page 94: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/94.jpg)
build your own tools
![Page 95: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/95.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/96.jpg)
adding new files to subversion repository
tortoise (on windows), but with limits
bash-fu
![Page 97: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/97.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/98.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/99.jpg)
get counts of each exception
get all exception types from log file sort them
get unique list
![Page 100: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/100.jpg)
windows scripting host
![Page 101: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/101.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/102.jpg)
comparisonsbash
wps
bash
wps
![Page 103: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/103.jpg)
use .net types within power shell scripts
implemented with .net
![Page 104: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/104.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/105.jpg)
.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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/106.jpg)
automating com
![Page 107: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/107.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/108.jpg)
“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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/109.jpg)
![Page 110: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/110.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/111.jpg)
![Page 112: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/112.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/113.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/114.jpg)
justifying automation
![Page 115: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/115.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/116.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/117.jpg)
don’t shave yaks!
![Page 118: the productive programer: mechanics](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/118.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022042701/55b1471cbb61eb87338b45e1/html5/thumbnails/119.jpg)
resources
ThoughtWorks
© 2008, Neal Ford
Published by O’Reilly Media
The Productive Programmer
Photos by Candy Ford
ISBN: 978-0-596-51978-0