Step 0/1
● create the directory structure
● add Symfony2 classloader as submodule
● init and update submodule
● (optional) create an empty class
Bengaluru, 20-22 November 2011
Step 2
● write the test with the smallest
amount of code you think it's
necessary
Bengaluru, 20-22 November 2011
Step 3
● add the Vertex class
● add the Graph class
● add an empty solve() method
for the algorithm class
Bengaluru, 20-22 November 2011
Step 5
● added all the methods
needed by the Dijkstra::solve()
● need to implement Graph::calculatePotentials()
Bengaluru, 20-22 November 2011
Step 6
● a test is added for the Graph class
Bengaluru, 20-22 November 2011
Step 7
● calculatePotentials() is tested
● half of our test-suite passes
● switch back to the Dijkstra's test
Bengaluru, 20-22 November 2011
Step 8
● minor tweaks to make all the tests pass
Bengaluru, 20-22 November 2011
Step 9
● potentials are assigned in the Graph class
but they should belong to the algorithm,
what about refactoring the code?
● since we move the only tested method of Graph
into Dijkstra's class, we can delete the GraphTest
Bengaluru, 20-22 November 2011
Step 10
● since we like to be OO, we can connect
vertices through objects, and not
arrays anymore
Bengaluru, 20-22 November 2011
Step 11
● we now need to fix the code which
uses vertices' connections as arrays
Bengaluru, 20-22 November 2011
Step 12
● the library seems pretty complete
● PHPDoc is added
Bengaluru, 20-22 November 2011
Step 13
● Oooops, we forgot to test a scenario:
in Dijkstra's algorithm we need vertices
connected by positive distance
● a test is added, verifying an exception
is raised through annotations
Bengaluru, 20-22 November 2011
Step 20
● what about calculating the path between
not-connected vertices?
It should return null, so code is refactored
Bengaluru, 20-22 November 2011
Step 21
● Dijkstra::solve() seems to do too
much things, so we split the method
● first demand potentials' calculation
● second demand path finding
● third demand raising the negative-potentials'
exception
● enter phploc
● enter code-coverage
Bengaluru, 20-22 November 2011