Iterative Design Process and Functions in Processing
1. From last time…
•
Quiz 2: Variables, Conditionals, & Loops!
•
We started to organize our sketches by defining
functions and simplifying our draw loop!
•
I sent out / posted expectations for Iteration 1!
•
I’ve cancelled class next Monday, 10 Feb 2014
3. Expectations
We will have 5 groups:!
! 1 GenArt, 1 DataViz, and 3 Game groups!
•
•
Mon, 17 Feb: you will show Iteration 1 to your
group and take notes (4–5 minutes per student)!
•
Wed, 19 Feb: you will submit your code, the
notes you took in class, and an Iteration 2 plan
before class (probably via Sakai…)
4. Feedback
•
What works? What do you like?!
•
What doesn’t work? How could it be improved?!
•
Any other thoughts or comments?
8. “Every piece of knowledge must have a
single, unambiguous, authoritative
representation within a system.”
The Pragmatic Programmer!
Hunt & Thomas on the Principle of Don’t Repeat Yourself (DRY)
9. DRY vs. WET
•
Non-DRY coding is often called WET coding:!
! - Write Everything Twice!
! - We Enjoy Typing!!
•
If you are repeating yourself in code, you should
automatically start thinking about functions…
11. Random Fill Color
void setRandomRGBFillColor() {
fill(random(255),random(255),random(255);
}
“This function takes no arguments, sets the fill color
to a random RGB color, and returns nothing.”
12. Random Positions
float randomXPosition() {
return random(width);
}
!
float randomYPosition() {
return random(height);
}
“This function takes no arguments, generates a
random value based on width, and returns a float.”
14. Arguments
•
When need a function to use a value that we give
to it, we give it arguments!
•
size(400,300); has two arguments!
•
Arguments are said to be “passed” to the function,
and must follow some rules:!
! - they must have the correct number of arguments!
! - they must have the correct type of arguments
15. Passed by Copy
•
When arguments are passed, they are said to be
“passed by copy”!
•
This means that your argument is duplicated
(copied) and the copy is handed to the function!
•
The function can use/abuse the copy and return
a value, without ever affecting the original value
passed in