Upload
vc-dig1108-fall-2013
View
218
Download
0
Tags:
Embed Size (px)
Citation preview
INTRO TO SERVER SIDE DEVELOPMENTWeek Eight
Thursday, October 24, 13
Concept Review
FunctionsConditionalsLoops
Thursday, October 24, 13
KeywordsA keyword is a word or identifier that has a particular meaning in a programming languageIn many languages keywords are reserved words that identify a syntactic form.They cannot be used as the names of variables or functions.
Words used in control flow, like if/then/else are keywords.
Operators: + - == <= and or
Conditionals: if elseif else
Looping: while do for foreach as
Functions: function return
Thursday, October 24, 13
Keyword Examples/** * Reduce any integer to an arbitrary number between 1 and 5 * @param integer $argument greater than 0 * @return integer between 1 and 5 */function reduce( $argument ) {if ( $argument >= 0 and $argument < 5 )return $argument + 1;
if ( $argument > 5 and $argument <= 10 )return $argument - 5;
if ( $argument == 5 )return $argument;
return reduce( (integer) $argument / 2 );}
Thursday, October 24, 13
Rules of the Code DojoPair Programming:
Pilot-Copilot
One person is the pilot and does the typing
One person is the copilot and tries to talk the solution out
Everyone else is passengers (quiet while flying!)
Timed for X minutes, then:
The pilot becomes a passenger, the copilot becomes the pilot, a passenger becomes the new copilot
Repeat until the problem is solved, everyone has been pilot and copilot, or we run out of time
Thursday, October 24, 13
Rules of the Dojo cont.Test Driven Development:Red-Green-Refactor
Red: the pilot cannot write any production code until there is at least one failing test
Green: the pilot should only write production code that attempts to satisfy the current failing tests, save and rerun frequently
Refactor: Once all tests are passing, look for opportunities to simplify or improve readability before moving on
Don't talk while Red:
Only the pair can talk while the timer is running
Allow the pair time to figure out the next steps on their own
Thursday, October 24, 13
Dojo AssignmentWrite a set of functions that all accept exactly two parameters and provide the functionality of a basic calculator: addition, subtraction, multiplication and division. Use simple assertion tests to develop in a test driven manner: assert( 'add(1,1) == 2' ); assert( 'sub(4,2) == 2' );Ensure that your test covers positive and negative numbers for all operations and multiplication or division by zero. The program should never produce a Fatal Error, so handle error conditions internally
Thursday, October 24, 13
Retrospective
What did we do well that we should try to do again?
What did we do poorly that we should try to correct?Did we achieve our goals and why or why not?
Thursday, October 24, 13