GW SDAB | DEV TOOLS
Hervé Vũ Roussel
September, 12th 2012
1
Point of views
Questions?
Ask as they come to you!
Agenda

 SVN
 ANT
 JUnit
 Ticketing system

4
5
France
Vietnam
Hervé Vũ Roussel

Unusual name
Career choice
Brain surgeon
Engineer
Astronaut
B.S.,GWU
Honors Scholarship
Gelman Library
CS department
Civil Engineering department
Weekends
Web dev at French consulate
M. Eng., Cornell University
Going to classes
ME

Siemens Medical Solutions, 3.5k emp.
ME

CA (Computer Associates), 15k emp.
Unstoppable
Day 0 | Linked Senior
Day 1 | Linked Senior
Day 2 | Linked Senior
Day 3 | Linked Senior
Day 4 | Linked Senior
Day 5 | Linked Senior
Day 6 | Linked Senior
Day 7 | Linked Senior
Day 8: Happy seniors | Linked Senior
Day 9: More happy seniors | Linked Senior
Today | Linked Senior
Office | Linked Senior
ME

Team | Linked Senior
More team | Linked Senior
Amazing adventure | Linked Senior
40
School VS Real world
Team size
Team location
Project life
Complexity
Customers
47
48
Where will you store your SD code?

To: hroussel@gmail.com
Attachment:
2003-02-01-post-simha-pres.zip

49
Storage
Concurrent access
Version tracking
History
Architecture

54
Hands on | Project
 Project: ZooZooPet
 Educational game for kids

 Web & Android version
 API team

 Company

55
Hands on 1 /3
 Development stage
 Teams
 Team #1: Make the Lion speak
 Team #2: Make the Tiger speak

 Goal: 1.0 release

56
Initial download: svn checkout

57
Code
Submit code: svn commit

59
Submit code: svn commit

60
Submit code commit

History view on repo

61
svn log
svn log [path]
com/linkedsenior

games

video

audio

tic-tac-toe

sudoku

word-search

63
svn diff
svn diff
What was I working on?
Synchronize: svn update

67
68
2-way merge

69
2-way merge GUI

70
71
SVN | Workflow
Synchronize
• svn checkout
• svn update

Publish

Work

• svn commit

• svn add
• svn mkdir
• svn del

Resolve (optional)

Review changes

• svn resolve
• svn merge

• svn diff
• svn status
• svn revert
72
Hands on 1/3 | Outcome

73
ZooZooPet | Best game ever
 1.0 released (1 billion download)
 Thinking about 2.0 features
 More animals
 Team#2 assigned

 Bug found in public release of 1.0!

74
Hands on 2/3
 1.0 released
 Bug #1 filed
 Bug fix on 1.0, release 1.1
 2.0 release

75
Release management
Fix version 1.0 in the wild
Tagging
Tagging 1.0
svn switch [rev] [path]
Creeped up bug
20 sec.
Time to switch revision
30 sec.
Time to clean re-build app
5 min.
Time to find if bug exists
2 sec.
Wiping sweat
<-- 150 rev. -->
Num of rev between v1.0 and v1.8
(20+30+5*60)
*
log2(150)
Calculating…
42 min 6 sec

Time to find guilty rev
Branching
Hands on 2/3 | Outcome

90
svn copy
 Tagging
svn copy -r {rev} http://.../trunk http://.../branches/1.x

 Branching
svn copy -r {rev} http://.../trunk http://.../tags/1.0

91
svn copy
ZooZooPet

trunk

tags

branches

1.0

1.x
92
Problem with evolution of code

93
SVN: 3-way merge

94
Best practices

 What to version control?
 When to commit?
 What to say?
 Trunk policy

95
96
97
98
Runnable
Deliverable
Release early, release often
Versatile build
Complex builds
Overview

 Scripting language
 XML based
 Written in Java

104
Hands on 3/3
 Write a build file for our application
 Follow instructions on SetupAnt wiki page

 Follow instructions on HandsOn3 wiki page

105
Sample build file

106
Target (order)
<target name="init">…
<target name="compile" depends="init“…
<target name="dist" depends="compile“…

107
Target (function body)
<target name="compile" depends="init"
description="compile the source " >
<javac srcdir="${src}" destdir="${build}"/>
</target>

108
Some built-in ANT tasks (API)
<mkdir dir="${dist}/lib"/>
<delete dir="${dist}"/>
<javac srcdir="${src}" destdir="${build}"/>
<jar jarfile="${dist}/lib/MyProject${DSTAMP}.jar" basedir="${build}"/>

109
Variables
<property name=“compile.debug" value=“true"/>

<javac srcdir="src" destdir="build"
debug="${compile.debug}" />

110
Running

111
Advanced ANT
113
114
YAY!!
WHY? | TESTING
WHY? | TESTING
What is it?| Test

Initial state
Scenario
Verification

118
What’s JUnit?
JUnit sample code
@Test
public void simpleAdd() {
Money m12CHF= new Money(12, "CHF");
Money m14CHF= new Money(14, "CHF");
Money expected= new Money(26, "CHF");
Money result= m12CHF.add(m14CHF);
assertTrue(expected.equals(result));
}

120
JUnit | Running
JUnit | Reporting
Test driven development
1. Create a
new test

4. Repeat
steps 2 & 3
until test pass.

2. Run test

3. Code

123
TDD example #1
TicTacToe t = new TicTacToe();
t.makeMove(Position.TOP_LEFT);
t.makeMove(Position.TOP_RIGHT);
t.makeMove(Position.MIDDLE_LEFT);
t.makeMove(Position.MIDDLE_RIGHT);
t.makeMove(Position.BOTTOM_LEFT);
assertTrue(t.getWinnerId(), 1);

124
TDD example #2
TicTacToe t = new TicTacToe("John", "Jim");
t.set(Token.X,
t.set(Token.Y,
t.set(Token.X,
t.set(Token.Y,

0,
2,
0,
2,

0);
0);
1);
1);

t.set(Token.X, 0, 2);
assertEquals(t.getWinner(), "John");

125
Test as living documentation
127
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget
Bust or Budget game rule
class BustOrBudgetGameTest {
@Test
void itShouldEndWhenThereIsOnlyOnePlayingTeam()
{
// Given ...
bobGameDriver.startGame(team1, team2);
// ...
// When ...
bobGameDriver.endTurn(team2, true);
assert bobGameDriver.teamInPlay.size == 1;
// Then
assert bobGameDriver.matchOver == true;
}
}

138
Poll: When to run tests?
1. Before a major deadline
2. After major code change
3. When Prof. Simha looks over your

shoulder
4. When Prof. Parmer looks over your
shoulder
5. All of the above
6. None of the above
139
Fixing a bug
Finding the culprit
7 stages of debugging
println “Hello world :)”

StageI: Denial
println “Before call”
println “After call”
Stage II: Acceptance
println “test”
println “bla”
println “here”
Stage III: Depression
println “1”
println “2”
Stage IV: Acceptance
println “a”
println “aa”
println “aaa”
Stage V: Fatigue
println “!)(@&#$!!!”

Stage VI: Anger
println “why”
println “god”
println “oh”
println “why”
Stage VII: Despair
Deliverance
The bottleneck
When to test?
Rethinking testing
Build tools | Continuous integration
Build tools | CI Report

155
156
157
Bug submission
Bug lifecycle
Bug search
Organization tool
Collaboration tool
Context | Ticket
Velocity
165
166

GW SDAB Dev Tools 2012

Editor's Notes

  • #3 During this talkExpress my opinionAs you move on with your careerYou may find people with different opinionsWhen you talk to these peopleAll I want you to remember Is that I was right
  • #5 Why?Most commonJoel Spolsky12 Steps to Better Code
  • #6 … Let me introduce myself
  • #18 At the same time!
  • #23 $1M
  • #24 2 promotions in 2 yearsManager of dev teamYoungest managerLed team of 5, within team of 40 spread over in 4 continentsDelivered AV/AS sig to 3M+ customers (AOL, Verizon, Fortune 500 etc.)Earned more money than my parents combined
  • #25 … Looking for a challengeUse tech to empower
  • #26 …Friend tells me about Charles
  • #28 … Build prototype1st customer
  • #29 …Great achievements
  • #32 … Build beautiful interface&gt;&gt; Pull out table tablet
  • #33 …Deliver to kiosks, tablets
  • #34 …We use tech to supportwellness &amp; prog at senior communitiesAlexandria, VA
  • #36 Customers in 30 states11 people in our team
  • #38 …We work hard but have fun too
  • #39 Unlimited vacation
  • #40 Learning opportunityHumbling experienceToughest challenge
  • #41 …I like to think that …great soft eng product …is the result of the effort of a great teamLed by vision and strategyEveryone on the team is moving together in the same directionIn order to be efficient, need for structureTools help
  • #42 …Before I talk about toolsHighlight the differences
  • #43 …Work with a lot more peopleCommunication (MMM)Everyone is differentCollaborate and come together on product
  • #44 …Having worked at CA
  • #45 … Land on project with few years of existenceExpected to last more yearsProject needs to be sustainableand maintainableDecision are made for the long term
  • #46 … Land on project with existing codeMore developers, more code: dauntingCode not written by youUnderstand the existing and improve on it
  • #47 …So far you have been dealing with nice professors$$$Expectation, Support
  • #51 …First feature of SVNImportant because:Code=Asset, IPBackupSecure locationRestricted access
  • #52 …Second feature of SVNImportant because:Collaborationand sharing
  • #53 …Third feature of SVNAudit &amp; reviewWho, when, whatRelease management
  • #54 1972: SCCS (Bell Labs)2000: SVN (Apache)Most commonBloomberg migrated to SVN in 2010Chromium OSSwas using in SVN as of 20102008: GitHub - Git, Gitorious - Git, BitBucket – Mercurial (Distributed)
  • #55 … SVN is made up of 2 components:ServerClient
  • #58 …When you join a project and are granted access to the codeThe first thing you will do isStorage = File structureLocal/working vs repo
  • #59 … Edit code (working copy)
  • #60 Uploadchangeset to serverAdd, modify, deletesvn add, svnmkdirPublish to everyoneWho, when, is automatically recorded with what.
  • #62 …Commit creates a new revCreate new, not modifyLatest rev. no. auto-incrementsEach commit results in snapshot of entire file system treeDeletefile = Removea file from future revision, still exists in past revision
  • #63 Review, track progressWay to communicateList history of changes@Head
  • #64 …Ifproject is properly structured, an interesting thing to do is2nd dimension
  • #65 …If you want to get more details on a changesetCompare file and folder changes
  • #67 …Another use case for diff
  • #68 …Other developers will be working on same repo at the same timeSync by downloading latestcode from server
  • #70 …When you do an SVN update, you may run into an interesting scenarioSame portion of the fileShared data w/ concurrent R/W What design change to avoid conflicts?
  • #71 ….When yourun into conflictsContent of working copy need to be selected
  • #77 …Two common scenariosin soft eng delivery
  • #78 …During dev, typically @HEADDebug version in the wildFind last revision thatledto release
  • #79 … Use technique calledtaggingBookmark revision with label
  • #80 …Here label is “1.0”
  • #81 Revert to state of codebase to given point in time
  • #82 … Customer reports bug. Latest release was 1.8, didn’t exist in 1.0Find bug by finding rev that introduced the bugDivide and conquer
  • #85 Run steps that leads to bug
  • #86 Customers is on my back
  • #90 …Another common scenario is maintaining a releaseFix bugsDivert from main line of devIsolation
  • #91 Main line of dev = trunkEach line has own release, purpose1.xTrunkSwitch to branch
  • #92 Technically, branch = tagPurpose, branch != tag
  • #93 …SVN copy: snapshot of revision subtree
  • #94 Can you spot it?
  • #95 … Bug fix is branchNeed to port to main line of dev
  • #96 What to version control?Everything you need to buildSource codeResources (config, properties file, etc.)Exclude Generated (class files)Large files: library binariesStatic filesWhen to commit?Too few VS too many changesCohesiveness What to say?Commit commentsTrunk policyMin requirementDon’t break the trunkEveryone is using itMust compileMust pass unit tests (tests coverage)
  • #98 StorageCollaboration, communicationRelease managementRecommendation: use oneGoogle codeGithub
  • #100 …Running your app is necessary in order to testWeb:deployed to web serverMobile:SimulatorDesktop: IDE
  • #101 …Building your app is necessary in order to deliver to end userReady to useWith build tool, you create script to automate steps to have your app in a deliverable state.Web: deployed to web serverMobile: deliver to app storeDesktop: deliver installer to web or CDDistribute for betaPhone Ad-Hoc build Provisioning Portal
  • #102 Concept popularized by OSS world in late 90sTight feedbackloop with usersCommon todayAdvocated by GoogleToday’s norm:users expect frequent updatesLS = ~6, 7 production release per monthWhy automate? Expected to build veryoften.
  • #103 …Projects are expected produce different buildsProduce build for target profileDev: debug, local, unsecuredProd: optimized, cloud/domain, securedProduce build for target platformsWhy automate? Consistentparameterized build.
  • #104 …In academia, run onlyOr simple build with basic steps: compile, link, package or deployLinked Senior4 web projects2 compiled languagesCloud integration100+ library dependenciesDigital signatureEmail notificationInternal web update500+ lines long with 30+ stepsAmazonLarge companiesDedicated build teamsFirefoxInstructions to run a build gives me a headachehttps://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions?redirectlocale=en-US&amp;redirectslug=Build_DocumentationBefore you can build Firefox, you&apos;ll need the build tools listed below and a few gigabytes of free disk space. Builds will be slow unless you have at least 2GB of RAM.Builds do more
  • #108 Targets = functionTargets can be executed on their own
  • #113 Built-in ANT tasksArchive TasksAudit/Coverage TasksDeployment TasksDocumentation TasksFile TasksMail TasksSCM Taskshttp://ant.apache.org/manual/tasksoverview.htmlWrite your custom taskExternal ANT tasks (Third party)
  • #114 Recommendation: do you need to build? Web apps
  • #116 Have to do itSD storyManualTediousError prone (missed tests)
  • #117 Beautiful, qualityHappy customers
  • #118 … Who here has writtennew feature and broken an existingcollaterally?Write code = risk of changing qualityEvolution of codeis unavoidableFramework = easy to run testSafety netRefactor = clarity
  • #120 Unittesting framework VS integrated1 test per class1 test per componentVery fast
  • #121 Currency adderRegular java@Test annotationintercepted by JUnit
  • #124 …Working new feature?Write test first
  • #125 …Start feature byBDDHelps designTend to write simple code
  • #126 Easy to changedesignNot restricted by existing classes
  • #127 …Doc drifts away from code (design changes, new features)Doc often has low priorityTest must passTest must compileTight bond with actual codeSimpleHigh level
  • #129 Spend as much as possible w/o going over budget
  • #130 Charles’ turn
  • #131 Hit / stay
  • #141 https://linkedsenior.unfuddle.com/a#/projects/4/tickets/by_number/1677I write a test
  • #142 Excellent steps to reproduceNo crash = doesn’t work as expectedWorst bugs No stacktraceNo starting pointEven with stacktrace, real cause maybe somewhere elseNPEClassCastException
  • #143 …Searching for cause for bug is painful: That’s why they invented debuggersCowboy style
  • #147 Short &amp; sweetPragmatic
  • #151 5 minutesto edit code
  • #152 Find the cause:95%
  • #153 When to test?Every time code changesWhy?early feedbackOverkill?So what?
  • #154 Wasting time running even if automatedHave someone else runs?ToolsSVN client to download codeBuild scriptAutomated tests=&gt; Integrate the 3?
  • #155 Continuous integrationBuild serverNotify &amp; report
  • #156 Early feedbackIf fail, still fresh
  • #157 Web apps: SeleniumJavascript: JasmineRecommendation: Give unit testing a try
  • #159 Communication with external/internal usersSteps to reproduce are important
  • #161 Search for dupsReopen bugKB (How did you fix this?)
  • #162 Not just for bugsNew featureRoadmap featureIdeasNew features come from: users, yourselfHard to keep track
  • #163 Agile envSmall iterative cyclesListof ticketsAssignTODO list on steroidFocus, track progress
  • #164 Ticket tied to IDE resource filteringTicket tied to SVN commit comments
  • #165 … In one cycle, you close 20 tickets for total of 33 pointsIn another cycle, you close 15 tickets for total of 27 pointsTicketing system allows you to track thisVelocity ~= 30 points per cycleVelocity = speed at which you release featureAbility to predict your release scheduleNew feature? When is it going to comeout?Provide better estimates = happy customers
  • #166 Recommendation: use one even if it’s excel
  • #167 Streamline communicationStructure your workflowGuidelines