Slides originally by Lucas Zamprogno
What happened in C0?
You wrote tests for an existing implementation
What will happen in C1?
You will implement it yourself!
(And run your tests from C0 against your own implementation)
What's C1?
Examples:
"what departments have courses with averages higher than 90%?"
"What courses in CPSC have a high fail rate?"
Answer queries about UBC courses.
{
"WHERE":{
"GT":{
"courses_avg":97
}
},
"OPTIONS":{
"COLUMNS":[
"courses_dept",
"courses_avg"
],
"ORDER":"courses_avg"
}
}
{ result:
[ { courses_dept: 'epse', courses_avg: 97.09 },
{ courses_dept: 'math', courses_avg: 97.09 },
{ courses_dept: 'math', courses_avg: 97.09 },
{ courses_dept: 'epse', courses_avg: 97.09 },
{ courses_dept: 'math', courses_avg: 97.25 },
{ courses_dept: 'math', courses_avg: 97.25 },
{ courses_dept: 'epse', courses_avg: 97.29 },
{ courses_dept: 'epse', courses_avg: 97.29 },
{ courses_dept: 'nurs', courses_avg: 97.33 },
{ courses_dept: 'nurs', courses_avg: 97.33 }
]
}
Answer queries about UBC courses.
Now the "how"...
...
...
(recursion in practice)
{
"WHERE":{
"GT":{
"courses_avg":97
}
},
"OPTIONS":{
"COLUMNS":[
"courses_dept",
"courses_avg"
],
"ORDER":"courses_avg"
}
}
Query handler
(recursion in practice)
{
"WHERE":{
"GT":{
"courses_avg":97
}
},
"OPTIONS":{
"COLUMNS":[
"courses_dept",
"courses_avg"
],
"ORDER":"courses_avg"
}
}
Query handler
Body
handler
Options
handler
(recursion in practice)
{
"WHERE":{
"GT":{
"courses_avg":97
}
},
"OPTIONS":{
"COLUMNS":[
"courses_dept",
"courses_avg"
],
"ORDER":"courses_avg"
}
}
Query handler
Body
handler
Options
handler
MComparison
SComparison
...
(recursion in practice)
{
"WHERE":{
"GT":{
"courses_avg":97
}
},
"OPTIONS":{
"COLUMNS":[
"courses_dept",
"courses_avg"
],
"ORDER":"courses_avg"
}
}
Query handler
Body
handler
Options
handler
MComparison
SComparison
...
(Also office hours get insane near deadlines)
TDD and testing can help you break down the high level goals -- addDataset(), performQuery() -- into smaller, easily testable tasks: saveDatasetToDisk(), validateQuery().
Write these tests first, make sure they fail, then write the code to make them pass