A 74-Step Account Of My 7-Year Old Daughter’s First Programming Experience
The First Of Many Lessons On Teaching My Daughter How To Code
Today I had a crazy thought. What if I were to teach my kids how to code? As my 3 and 5-year old boys were busy playing with their Legos, I asked my 7-year old daughter if she wanted to learn how to code. She enthusiastically said yes. I immediately just realised what I had gotten myself into. How in the world am I going to teach a 7-year old to code?
Here’s a step-by-step account of what happened. If you’re a nerd daddy like myself, this might be a fun activity with your kids.
Getting Started
1. Daddy creates a brand new single-view project in XCode.
2. Daddy adds a label on the main iPhone storyboard
3. Daddy sets the label’s text to some string (ex: “daddy loves you”)
4. Daddy runs the simulator and see the string displayed on the simulator
My Daughter’s First Ever Encounter With XCode and Interface Builder
5. Daughter double clicks on the label in the story board
6. Daughter changes the label’s value to something (ex: “i love you too daddy”)
7. Daughter presses enter to have the label remember the value
8. Daughter presses cmd+s to have the project remember our changes
9. Daughter presses cmd+r to launch the simulator
10. Daughter sees her text displayed in the simulator
Sweet Sweet Victory
11. Daughter giggles
12. Daddy giggles
Unexpected Bonus
13. 5-Year old Son: “can I do it too?”
14. Daddy: “of course”
15. Daughter: “I’ll show you”
16. Son repeats steps 5 through 11
Awesomeness
17. Daddy repeats step 12
It Just Keeps Getting Better And Better
18. Daughter: “can we try again?”
19. Daddy “of course”
20. Daughter repeats steps 5 through 11
21. Daddy repeats step 12
22. Son: “I’m bored, I’m gonna play with Legos now”
23: Daughter: “This is fun but can we try something more difficult?”
24: Daddy: “That’s my girl”
Types, Variables, Values, Assignment and Instantiation — Yeah I Know!
25: Daddy adds an outlet property in ViewController.h
@property (nonatomic) IBOutlet UILabel* label;
26: Daddy changes the label’s value in ViewController.m to display a variable’s value
- (void)viewDidLoad
{
[super viewDidLoad]; ////////////////////////////////////
int a = 1;
int b = 2;
int c = a + b;
//////////////////////////////////// self.label.text = [NSString stringWithFormat:@”c = %d”, c];
}
27. Daughter: “Oh, what’s this?”
28. Daddy: “You see those 3 lines between those pretty lines there?”
29. Daughter: “Uh huh”
30. Daddy: “That’s going to be our lesson for today. Read the first line out.”
My Daughter Reads Her First Line Of Code Ever
31. Daughter: “Int space a space equal space one dot and comma”
32. Daddy: “Alright, let’s leave the spaces out and it’s equals, not equal. Also, it’s a semicolon honey, not a dot and comma, but let’s leave that out too. Ok, let’s read it out again”
33. Daughter: “Int a equals 1″
34. Daddy: “Woohoo, you read your first line of code!”
35. Daughter repeats step 11
36. Daddy repeats step 12
Learning About Types
37. Daughter: “Daddy?”
38. Daddy: “Yes honey”
39. Daughter: “What’s an int?”
40. Daddy: “Good question. That’s very easy honey. It means that’s a number.”
41. Daughter: “Oh ok.”
First Ever Encounter With Variables and Values
42. Daddy: “You know what a is called? It’s called a variable. Let me show you what a variable is.”
43. Daddy grabs his empty coffee cup and drops one Lego piece in it
44. Daddy: “You see honey, a variable is like a cup. It can be empty or it can have stuff inside. The stuff inside is called its value. In this case it holds one piece of Lego. That means its value is …
45. Daughter: “one”
46. Daddy: “Exactly! So look at the second line. Read it out. What’s the variable’s name and what its value?”
47. Daughter: “Int b equals 2. The variable is b and its value is 2. It’s like two pieces of Lego in a cup”
48. Daddy: “Yes! Exactly! Now read the third line. What’s the variable’s name and what’s its value?”
49. Daughter: “Int c equals… uhhmm a+b? The variable is c and the value is … uhhmmm a+b?”
50. Daddy: “That’s right honey! That’s exactly it! You know what that means? That means that if we change a or b, c changes. Wanna see?”
51. Daughter: “What do you mean?”
52. Daddy: “Let me show you. So, first of, what do you think the value of c is right now? If c equals a plus b and a equals 1 and b equals 2?”
53. Daughter: “3 of course”
54. Daddy: “Of course” *smile* “So run this program and let’s see what it shows us. Remember how to run a program?” *smile*
55. Daughter: “Uhmm command and uhmm R”
56. Daddy: “Excellent!”
57. The simulator starts up and the label’s value shows “c = 3″
Learning about Variable Instantiation
58. Daddy: “So let’s change the value of a to say 300″
59. Daddy shows his daughter how to use the arrow keys to move to the right line and the right character and how to use backspace to erase
60. Daughter erases the 1 on the first line and types 300
61. Daddy: “Great, now change the value of b to something big, like 850″
62. Daughter erases the 2 on the second line and types 850
63. Daddy: “Great, what’s c now?”
64. Daughter: “Daddy, those are big numbers, how should I know”
65. Daddy: “See, that’s where the computer will helps us. Look the computer will tell us what c is. Just run it”
66. Daughter as she presses cmd+R: “Daddy how is the computer so smart?”
67. Daddy smiles
68. The simulator launches and shows the label’s value as “c = 1150″
69. Daughter: “Wow, one thousand, one hundred and fifty. Wow”
It Has Begun …
70. Daughter: “Let’s see what happens if I do this”
71. Daughter changes the values of a and b to some random seven-digit numbers and she runs the program again
72. The simulator launches and shows c equals some huge number
73. Daughter is amazed and she repeats steps 71 and 72 several times
One Proud Daddy
73. Daddy watches in amazement as his daughter is coding her first program ever.
74. Daddy repeats step 12 and whispers in disbelief “My baby is coding!”