Presentation for Causerie at ADMB Bruges, Thursday 12 February 2009.
Audio will be added once I have it - the pictures are nice, but I'm not sure they make that much sense without the narrative (or do they? What do you think?)
(NB first slide is not a mistake - deliberately empty)
41. Manifesto again
We are uncovering better ways of developing
software by doing it and helping others do it.
Through this work we have come to value:
Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan
That is, while there is value in the items on
the right, we value the items on the left more.
www.agilemanifesto.org
42. Characteristics
Adaptive
Iterative
Fast
Practical
Communicative
Team focus
Based in values
64. Some tests
function testCamelCaseUpperEmpty() {
assertEquals(quot;Empty input should give empty outputquot;,
quot;quot;,
convertIdentifier(quot;quot;,CI_TEXT,CI_CAMEL_UPPER));
}
function testCamelCaseUpperOneChar() {
assertEquals(quot;Single char should map to upperquot;,
quot;Aquot;,
convertIdentifier(quot;aquot;,CI_TEXT,CI_CAMEL_UPPER));
}
function testCamelCaseUpperOneWord() {
assertEquals(quot;Single word should have initial upper and rest lowerquot;,
quot;Helloquot;,
convertIdentifier(quot;helloquot;,CI_TEXT,CI_CAMEL_UPPER));
}
function testCamelCaseUpperTwoWords() {
assertEquals(quot;Two words should have initial uppers and rest lower, space removedquot;,
quot;HelloWorldquot;,
convertIdentifier(quot;hello worldquot;,CI_TEXT,CI_CAMEL_UPPER));
}
function testCamelCaseUpperMessy() {
assertEquals(quot;Messy string should have initial uppers, rest lower, all spaces removedquot;,
quot;HelloFunkyWorldquot;,
convertIdentifier(quot; hELlO FunKy woRld quot;,CI_TEXT,CI_CAMEL_UPPER));
}
65. function convertIdentifier(src, srcType, dstType) {
var allWords = src.split(srcType.sepExp);
Passes the tests
var nonEmptyWords = allWords.filter(function(word) { return word != '';} );
var correctCaseWords = nonEmptyWords.map(dstType.calcCase);
var result = correctCaseWords.join(dstType.joinChar);
return result;
}
var CI_TEXT ={
sepExp: ' ',
joinChar: ' ',
calcCase: _toLower
};
var CI_CAMEL_UPPER = {
sepExp: /(?=[A-Z])/,
joinChar: '',
calcCase: _toInitialUpper
};
var CI_CAMEL_LOWER = {
sepExp: /(?=[A-Z])/,
joinChar: '',
calcCase: function(word, index) {return index == 0 ? _toLower(word) : _toInitialUpper(word);}
};
function _toLower(s) {
return s.toLowerCase();
}
function _toInitialUpper(s) {
return s[0].toUpperCase() + s.slice(1).toLowerCase();
}
66. var CI_TEXT = 0;
var CI_CAMEL_UPPER = 1;
var CI_CAMEL_LOWER = 2;
So does this
function convertIdentifier(s, from, to) {
var result;
if (from == CI_CAMEL_UPPER && to == CI_CAMEL_LOWER || from == CI_CAMEL_LOWER && to == CI_CAMEL_UPPER) {
// camelCase function doesn't deal with this conversion, but it's easy
if (to == CI_CAMEL_LOWER)
result = s.charAt(0).toLowerCase();
else
result = s.charAt(0).toUpperCase();
var end = s.length;
for (i = 1; i < end; i++)
result += s.charAt(i);
} else {
var undo;
if (to == CI_TEXT) undo = true; else undo = false;
var flag;
if (to == CI_CAMEL_UPPER) flag = true; else flag = false;
result = camelCase(s, flag, undo);
}
return result;
}
function camelCase(s, flag, undo) {
var l = s.split(' ');
var i = 0;
var lc = ' ';
var r = '';
while (i < s.length) {
if (s[i] == ' ' && !undo) {
lc = s[i++];
continue;
} else {
if (lc == ' ' && !undo) {
r = r + s[i++].toUpperCase();
lc = '';
} else if (undo) {
// in undo mode
if (i > 0) {
67. So does this
“simple”
!=
“the first thing that passes the tests”