0:00:17.020,0:00:18.240 CARLOS SOUZA: Thanks everyone for coming. 0:00:18.250,0:00:21.660 It's a great pleasure to be here at RailsConf. 0:00:21.660,0:00:24.060 Just so we know, who's go, coming to RailsConf 0:00:24.060,0:00:28.810 for the first time? Wow. That's amazing. 0:00:28.810,0:00:32.549 Cool. Welcome. And, we're gonna be talking 0:00:32.549,0:00:35.910 to you today a little bit about Coding Dojo, 0:00:35.910,0:00:38.550 and how you can use the Dojo to improve 0:00:38.550,0:00:45.550 your coding skills and become better developers. 0:00:45.820,0:00:47.890 My name's Carlos Souza, and this is my friend 0:00:47.890,0:00:51.840 David Rogers. We, we're both from Orlando,[br]Florida. We're 0:00:51.840,0:00:55.949 from Code School, and we love development[br]and we 0:00:55.949,0:01:00.070 love teaching. And that love for development[br]and for 0:01:00.070,0:01:03.920 teaching others how to developer brought us[br]to the 0:01:03.920,0:01:07.430 Coding Dojo, and we formed our Coding Dojo[br]group 0:01:07.430,0:01:09.570 back in Orlando a couple of years back. And 0:01:09.570,0:01:14.990 we ran that biweekly for about two and a 0:01:14.990,0:01:16.509 half years? And we also used it, the Coding 0:01:16.509,0:01:18.640 Dojo as a teaching tool. 0:01:18.640,0:01:20.520 So what we're gonna do here today is try 0:01:20.520,0:01:23.860 to teach you guys a little bit about our 0:01:23.860,0:01:27.909 experience running the Dojo, and we're actually[br]gonna run 0:01:27.909,0:01:31.729 a Dojo here with you guys, and hopefully you, 0:01:31.729,0:01:34.280 you can run Dojos on your own. At your 0:01:34.280,0:01:37.460 company, with your friends, in your local[br]meet ups. 0:01:37.460,0:01:43.299 And this is a message to all developers, right. 0:01:43.299,0:01:46.130 We're all developers here, even if you're[br]not, if 0:01:46.130,0:01:49.110 you don't spend your day-to-day coding, I'm[br]gonna ask 0:01:49.110,0:01:51.619 you to put on the developer hat for just 0:01:51.619,0:01:53.890 a little bit to understand where we're coming[br]from. 0:01:53.890,0:01:56.270 And then the problems that we're trying to[br]solve 0:01:56.270,0:01:58.100 with the Coding Dojo. 0:01:58.100,0:02:02.880 And we have different levels of exper- expertise,[br]as 0:02:02.880,0:02:06.049 developers. Maybe you're a beginner developer.[br]You're just starting. 0:02:06.049,0:02:08.758 You're on the first couple of years of, of 0:02:08.758,0:02:12.190 working with the software development, with[br]Ruby, with Rails. 0:02:12.190,0:02:15.100 Maybe you just graduated a Dev BootCamp. Maybe[br]you 0:02:15.100,0:02:17.720 just graduated college, or maybe you're going[br]through online 0:02:17.720,0:02:20.410 classes and learning how to program in Ruby[br]and 0:02:20.410,0:02:22.450 JavaScript and whatever. 0:02:22.450,0:02:24.389 Or maybe you're a little bit more advanced.[br]You're 0:02:24.389,0:02:28.040 more on the intermediate level. You've been[br]working with 0:02:28.040,0:02:30.639 the, some programming language and framework[br]for a couple 0:02:30.639,0:02:33.519 of years. You're starting to get more responsibilities[br]at 0:02:33.519,0:02:36.449 work. You're starting to lead projects. 0:02:36.449,0:02:39.720 And maybe you're even more expert. Maybe you've[br]been 0:02:39.720,0:02:43.180 working with software development for maybe[br]over a decade. 0:02:43.180,0:02:45.669 Maybe you're an architect. Maybe you're responsible[br]for the 0:02:45.669,0:02:50.160 architectural decisions in your company. And,[br]I guess, regardless 0:02:50.160,0:02:53.730 of the level of expertise that you're at,[br]you've 0:02:53.730,0:02:57.320 probably realized that this point, the technology[br]that you're 0:02:57.320,0:03:01.359 working with, it gets better. It evolves.[br]That's the 0:03:01.359,0:03:04.910 natural way of things. The tools that we use, 0:03:04.910,0:03:06.609 they are, they're getting better. 0:03:06.609,0:03:10.010 And this, especially in the open source community,[br]because 0:03:10.010,0:03:12.359 there's sort of a natural selection. If something[br]is 0:03:12.359,0:03:14.940 not good enough for the community, the community[br]will 0:03:14.940,0:03:18.750 naturally look for better ways of doing something,[br]for 0:03:18.750,0:03:23.940 better practices, for better tools, for better[br]frameworks. 0:03:23.940,0:03:27.910 Just as an example, Rails has an average of 0:03:27.910,0:03:32.900 a hundred commits every week. So, things change[br]very, 0:03:32.900,0:03:37.010 very, very fast. And, Rails is just one of 0:03:37.010,0:03:39.220 the projects, or the tools that you use on 0:03:39.220,0:03:42.010 your day to day, when you stop and think. 0:03:42.010,0:03:46.400 You're using Rails, you're using Ruby, you're[br]using, you're 0:03:46.400,0:03:49.579 using Bundler. You're using a, a variety of[br]open 0:03:49.579,0:03:54.229 source tools, and they're always changing.[br]Every day, there's 0:03:54.229,0:03:57.609 many changes going into those projects. New[br]features being 0:03:57.609,0:04:02.169 added. Old features being removed. Existing[br]features being changed. 0:04:02.169,0:04:05.070 And it's really, really hard to keep track[br]of 0:04:05.070,0:04:07.759 all the changes that are going on in all 0:04:07.759,0:04:10.120 the various tools that you're using. So, what[br]I'm 0:04:10.120,0:04:13.180 trying to say is that us, as developers, we 0:04:13.180,0:04:16.040 are not necessarily getting better at the[br]same pace 0:04:16.040,0:04:19.130 that our tools are evolving. It's very hard[br]to 0:04:19.130,0:04:21.220 keep track of all the changes that are happening 0:04:21.220,0:04:24.130 in the ecosystem. And still being able to[br]put 0:04:24.130,0:04:26.009 on your, your nine to five and pay the 0:04:26.009,0:04:26.900 bills. 0:04:26.900,0:04:31.120 And it's, it's good to look at other types 0:04:31.120,0:04:34.340 of artists, other people that work with creativity[br]or 0:04:34.340,0:04:39.950 art. Say, musicians and athletes, that also[br]rely on 0:04:39.950,0:04:42.940 their art, right, and they, they need to practice, 0:04:42.940,0:04:46.600 right. So martial artists, like the first[br]guy on 0:04:46.600,0:04:49.600 the, on the first slide, he goes to the 0:04:49.600,0:04:54.030 gym 24/7. He's practicing a lot, right. Musicians[br]- 0:04:54.030,0:04:57.130 they practice a lot before going into the[br]studio, 0:04:57.130,0:04:58.440 before putting on a show. 0:04:58.440,0:05:01.660 And. The microphone died. There's another[br]one. Is, is 0:05:01.660,0:05:07.780 there another microphone, perhaps? No? There's[br]just one microphone. 0:05:07.780,0:05:12.850 Oh man. That sucks. So. Well, so yeah. So, 0:05:12.850,0:05:17.060 all these athletes and artists, they spend[br]countless hours 0:05:17.060,0:05:19.210 in the gym or at the studio practicing their 0:05:19.210,0:05:22.040 art, so when the time comes to perform, they 0:05:22.040,0:05:24.630 are prepared. So they all practice. 0:05:24.630,0:05:27.680 You want to talk a little bit about practicing, 0:05:27.680,0:05:28.190 David? 0:05:28.190,0:05:32.510 DAVID ROGERS: Pass the mic. Yeah, so, I, you 0:05:32.510,0:05:36.010 know, the one key point here is that as, 0:05:36.010,0:05:37.950 as practitioners of an art or a craft, we 0:05:37.950,0:05:42.040 need to practice as well. Anybody read Malcolm[br]Gladwell's 0:05:42.040,0:05:45.200 book Outliers, or heard of Outliers? I think[br]the 0:05:45.200,0:05:49.810 one take away from Outliers is that, the one, 0:05:49.810,0:05:52.760 while it appears that some people are exceptional[br]and 0:05:52.760,0:05:55.420 live outside of the regular bell curve, what[br]it 0:05:55.420,0:05:57.660 actually turns out to be the case is that 0:05:57.660,0:06:01.140 they were given, or have spent, much more[br]time 0:06:01.140,0:06:05.230 practicing. That, that, on average, it's somewhere[br]around 10,000 0:06:05.230,0:06:07.850 hours worth of practice in order to become[br]an 0:06:07.850,0:06:10.020 expert in a particular field was, that was[br]his 0:06:10.020,0:06:11.470 assertation. 0:06:11.470,0:06:13.960 The one big take away from the book is 0:06:13.960,0:06:15.910 that, that is ind of summed up in one 0:06:15.910,0:06:18.330 quote there, that practice isn't the thing[br]that you 0:06:18.330,0:06:21.370 do once you get good. It is the thing 0:06:21.370,0:06:23.600 that you do that makes you good. And, some 0:06:23.600,0:06:26.440 of you might be saying, well, I practice.[br]Of 0:06:26.440,0:06:28.780 course I practice. I practice every day. I[br]practice 0:06:28.780,0:06:31.650 every day for nine hours, sometimes ten hours,[br]occasionally 0:06:31.650,0:06:35.330 twelve hours, sometimes twenty-four or seventy-two[br]hours at a 0:06:35.330,0:06:37.490 stint. And then eventually take a shower or[br]die 0:06:37.490,0:06:39.750 and fall into a coma. 0:06:39.750,0:06:42.430 But, the key thing to remember there is that 0:06:42.430,0:06:46.280 work does not equal practice. Like Carlos[br]was saying, 0:06:46.280,0:06:48.280 when you look at a martial artist or you 0:06:48.280,0:06:50.370 look at a concert violinist, or you look at 0:06:50.370,0:06:53.060 someone who practices a craft or a art for 0:06:53.060,0:06:57.240 their profession, they don't perform nearly[br]as much time 0:06:57.240,0:06:59.990 as they practice. There's a def- there's a[br]definite 0:06:59.990,0:07:03.370 separation between the performance of their[br]art and the 0:07:03.370,0:07:05.270 practice of their art. 0:07:05.270,0:07:07.490 So we can't really equate what we do on 0:07:07.490,0:07:11.210 a daily basis, nine to five, as practice.[br]That's 0:07:11.210,0:07:15.340 work. We need, do ship software. We need to 0:07:15.340,0:07:18.560 perform. We need to hit our deadlines. We're[br]concerned 0:07:18.560,0:07:22.710 with building stuff that works. Work time[br]is not 0:07:22.710,0:07:23.800 practice time. 0:07:23.800,0:07:27.210 Well, then that brings up the inevitable question,[br]how 0:07:27.210,0:07:30.020 then, do we practice what it is that we 0:07:30.020,0:07:34.020 do? And how should we practice what we do? 0:07:34.020,0:07:36.669 What does practicing code actually look like?[br]How do 0:07:36.669,0:07:38.600 I practice, as a programmer? 0:07:38.600,0:07:40.180 Well, one way we could do that is to 0:07:40.180,0:07:43.490 emulate how other artists practice their art[br]and their 0:07:43.490,0:07:45.370 craft. 0:07:45.370,0:07:49.990 C.S.: And we're talking about here, is, for[br]example, 0:07:49.990,0:07:53.960 martial arts. So we have the, the term Dojo, 0:07:53.960,0:07:57.050 which in martial arts means, the place where[br]people 0:07:57.050,0:08:00.210 practice those arts. And this is a term that 0:08:00.210,0:08:05.169 was coined by Dave Thomas of the Pragmatic[br]Programmers. 0:08:05.169,0:08:07.580 And he brought that to the programming world,[br]saying 0:08:07.580,0:08:10.360 we should set up a Dojo for programming, so 0:08:10.360,0:08:13.850 we can practice code. 0:08:13.850,0:08:18.300 D.R.: And the, the keys to a code Coding 0:08:18.300,0:08:20.790 Dojo is that we are providing, just like in 0:08:20.790,0:08:25.740 a martial arts setting, we're providing a[br]safe, collaborative, 0:08:25.740,0:08:30.300 non-competitive location at a, at a space[br]and a 0:08:30.300,0:08:34.820 time to practice together. We get together[br]and we 0:08:34.820,0:08:37.940 code. WE learn something. We actually practice[br]programming. WE 0:08:37.940,0:08:40.208 practice learning and teaching one another.[br]And we also 0:08:40.208,0:08:41.630 have a lot of fun. Just like you would 0:08:41.630,0:08:43.479 if you, has anybody taken martial arts of[br]any 0:08:43.479,0:08:46.110 sort? Yoga counts. Well, I'll give you yoga,[br]right, 0:08:46.110,0:08:48.070 we'll give you yoga, right. 0:08:48.070,0:08:52.820 So, that's, that's really the goal of the,[br]the 0:08:52.820,0:08:56.550 Dojo. But, how we actually live it out is, 0:08:56.550,0:09:00.790 just like in martial arts, we practice Katas.[br]And 0:09:00.790,0:09:03.620 a Kata in martial arts is this kind of 0:09:03.620,0:09:08.720 detailed choreography of very ritualized movements[br]that you practice, 0:09:08.720,0:09:11.810 either solo or in a pair or in a 0:09:11.810,0:09:14.800 group. And they don't really have a direct[br]translation 0:09:14.800,0:09:17.240 to, if I was a martial artist, fighting another 0:09:17.240,0:09:21.029 person. Like, I would not use my Kata skills 0:09:21.029,0:09:23.839 to win a battle. But, they teach me how 0:09:23.839,0:09:26.940 to punch. They teach me how to block. They 0:09:26.940,0:09:30.070 teach me how to evade, through the choreography.[br]So 0:09:30.070,0:09:32.010 that when the time comes to actually block[br]a 0:09:32.010,0:09:35.000 punch or throw a punch, my body remembers[br]even 0:09:35.000,0:09:36.670 though my brain is not thinking about throwing[br]a 0:09:36.670,0:09:38.029 punch here. 0:09:38.029,0:09:41.730 In programmer, as Carlos was saying, Dave[br]Thomas, Pragmatic 0:09:41.730,0:09:45.970 Programmer Dave, Prag Dave, coined this term[br]to describe, 0:09:45.970,0:09:47.400 along with Kent Beck and some of the other 0:09:47.400,0:09:51.100 guys, Ward Cunningham, tried to describe a[br]method of 0:09:51.100,0:09:54.000 practice inside of a Dojo. So inside of a 0:09:54.000,0:09:56.880 Coding Dojo, just like inside of a Karate[br]Dojo, 0:09:56.880,0:10:00.710 we practice Katas, which are choreographed[br]patterns of movements 0:10:00.710,0:10:03.890 that we practice either in solo or in pair, 0:10:03.890,0:10:08.320 to reinforce skills that we don't necess-[br]we wouldn't 0:10:08.320,0:10:12.080 necessarily use in the choreographed pattern,[br]but we would 0:10:12.080,0:10:14.290 use on a daily basis when we actually come 0:10:14.290,0:10:16.080 face-to-face with that variable that needs[br]to be punched 0:10:16.080,0:10:17.420 in the head. 0:10:17.420,0:10:19.690 And we break that down, when we're talking[br]about 0:10:19.690,0:10:24.180 choreographed patterns, inside of the Dojo[br]inside of a 0:10:24.180,0:10:28.750 coding Kata, as Prag Dave coined it, we're[br]talking 0:10:28.750,0:10:31.080 about test-driven development. And, regardless[br]of what you may 0:10:31.080,0:10:36.420 have heard earlier today, tests are not the[br]devil. 0:10:36.420,0:10:39.120 They will not, they are not a sin, and 0:10:39.120,0:10:40.810 a lot of the Pragmatic guys, a lot of 0:10:40.810,0:10:42.980 the guys that we're talking about, that coined[br]the 0:10:42.980,0:10:47.290 terms the Dojo and Katas, were in that deck 0:10:47.290,0:10:50.110 referring to just enough testing. 0:10:50.110,0:10:52.310 What we're doing in the Dojo is not just 0:10:52.310,0:10:56.040 enough testing. It is way-too-much testing,[br]so that we 0:10:56.040,0:10:59.870 can practice the art of testing. When we practice 0:10:59.870,0:11:02.320 martial arts, and we learn a Kata in martial 0:11:02.320,0:11:05.480 arts, we're not punching just enough. We're[br]punching a 0:11:05.480,0:11:08.350 whole lot, so that when the time comes to 0:11:08.350,0:11:10.690 actually punch, we know how much to punch[br]and 0:11:10.690,0:11:13.120 with how much force we're to punch. 0:11:13.120,0:11:14.770 C.S.: And it's, it's kind of, if you play 0:11:14.770,0:11:18.610 a musical instrument, you, and you practice[br]that musical 0:11:18.610,0:11:21.170 instrument, chances are, you're practicing[br]along with a metronome. 0:11:21.170,0:11:23.290 And I like to make that analogy between a 0:11:23.290,0:11:27.589 metronome and writing tests when you're practicing,[br]right. So 0:11:27.589,0:11:30.230 you need to metronome when you're practicing[br]music to 0:11:30.230,0:11:33.310 keep that pace, so you can focus on repeating 0:11:33.310,0:11:36.850 your movements very, very slowly, and with[br]very close 0:11:36.850,0:11:40.910 attention, so you can gradually increase the[br]speed to 0:11:40.910,0:11:43.589 which you play, to get to the point where 0:11:43.589,0:11:46.470 you're shredding that speed solo. And then[br]when you 0:11:46.470,0:11:49.029 play that live it just feels natural. 0:11:49.029,0:11:50.830 But, for you to get to that point, you 0:11:50.830,0:11:52.870 needed to start very slowly, and you needed[br]a 0:11:52.870,0:11:56.050 tool to assist you. In music, that's the metronome. 0:11:56.050,0:12:00.730 In coding, that's test-driven development.[br]That's writing tests. And, 0:12:00.730,0:12:03.200 like Dave said, in the Coding Dojo, we're[br]not 0:12:03.200,0:12:06.620 practicing just enough tests. We're practicing[br]a whole lot 0:12:06.620,0:12:08.880 of tests. So when the time comes for you 0:12:08.880,0:12:11.470 to write production code, you'll naturally[br]be able to 0:12:11.470,0:12:15.670 tell whether you need to test-drive that feature[br]or 0:12:15.670,0:12:19.660 not. 0:12:19.660,0:12:23.810 And one other thing that we practice is pair 0:12:23.810,0:12:26.690 programming. And pair programming is not just[br]sitting down 0:12:26.690,0:12:29.709 and coding next to someone. It requires a[br]set 0:12:29.709,0:12:33.360 of social skills. It requires knowing how[br]to suggest 0:12:33.360,0:12:36.220 a feature, knowing how to accept a suggestion,[br]knowing 0:12:36.220,0:12:38.300 how to accept a criticism, and not take it 0:12:38.300,0:12:41.370 personally. So there's way more to pair programming[br]than 0:12:41.370,0:12:44.300 simply sitting next to each other and either[br]watching 0:12:44.300,0:12:46.540 them code or telling them what to code. 0:12:46.540,0:12:49.600 D.R.: And, and again, like, like Kaikay was[br]saying, 0:12:49.600,0:12:53.480 these are, these are social skills. And while[br]they 0:12:53.480,0:12:57.610 might be accentuated inside of the Dojo, they[br]definitely 0:12:57.610,0:12:59.860 have a lasting impact as a programmer. I,[br]I 0:12:59.860,0:13:03.160 personally, and Kaikay, we both pair program[br]as a 0:13:03.160,0:13:06.440 part of our writing production code, as a[br]part 0:13:06.440,0:13:10.950 of our performant art, and we've found a huge 0:13:10.950,0:13:15.350 increase in our productivity whenever we selectively[br]and intentionally 0:13:15.350,0:13:16.170 pair with others. 0:13:16.170,0:13:17.510 Maybe we don't do it all the time. We 0:13:17.510,0:13:18.890 certainly don't do it all the time, because[br]sometimes 0:13:18.890,0:13:22.500 you just gotta get stuff done, right. But[br]when 0:13:22.500,0:13:24.750 we do pair, we know the etiquettes, we know 0:13:24.750,0:13:28.279 the social currency to be able to use one 0:13:28.279,0:13:30.980 of the styles of pair programming. Be it pilot, 0:13:30.980,0:13:33.399 co-pilot, where I sit back and Kaikay's on[br]the 0:13:33.399,0:13:37.830 keyboard and he types into the, into the editor 0:13:37.830,0:13:42.110 and I make suggestions, or I notice syntax[br]errors 0:13:42.110,0:13:45.029 or I ask him questions about what he's doing 0:13:45.029,0:13:46.700 and he tells me how he's going to do 0:13:46.700,0:13:49.520 something, and then we switch and I start[br]typing 0:13:49.520,0:13:52.440 and he plays co-pilot and helps keep me, navigating. 0:13:52.440,0:13:54.480 Or you use a ping-pong type approach. There's[br]lots 0:13:54.480,0:13:56.080 of different types that we can, that we can 0:13:56.080,0:13:59.089 use. For the Coding Dojo, especially when[br]we're talking 0:13:59.089,0:14:03.459 about small pairs or to practice pair programming,[br]in 0:14:03.459,0:14:06.029 this Coding Dojo we're gonna use a ping pong 0:14:06.029,0:14:07.589 approach. And in that, and that approach is[br]a 0:14:07.589,0:14:11.610 lot like playing ping pong. One person serves[br]the 0:14:11.610,0:14:14.730 ball by writing some tests, and the tests[br]then 0:14:14.730,0:14:18.550 fail, right. Test-driven development. We do[br]red-green-refactor. So the 0:14:18.550,0:14:22.180 tests fail. Then he passes the mic over to 0:14:22.180,0:14:25.440 the pair, his, his partner then writes some[br]code 0:14:25.440,0:14:27.910 to pass the test. They might talk, the pair 0:14:27.910,0:14:30.050 will talk through it, but write some code[br]to 0:14:30.050,0:14:32.880 pass the tests. And then, immediately writes[br]another test 0:14:32.880,0:14:35.279 that will fail, to serve the ball back across 0:14:35.279,0:14:37.120 the net to his partner. 0:14:37.120,0:14:39.010 We'll see an example of that a little bit 0:14:39.010,0:14:41.240 later. We'll do a, a, what's called a practice 0:14:41.240,0:14:43.580 Kata. But, Kaikay, why don't you tell us a 0:14:43.580,0:14:45.670 little bit more about the different types[br]of Katas 0:14:45.670,0:14:46.200 that we could do. 0:14:46.200,0:14:48.850 Anybody have any questions so far, before[br]we, before 0:14:48.850,0:14:51.149 we go on? Is everybody tracking on that, you 0:14:51.149,0:14:54.690 know, for, four to five fingers? Perhaps just[br]one. 0:14:54.690,0:14:57.220 One finger. No? OK. 0:14:57.220,0:15:01.250 C.S.: So there, there's different types of[br]Katas. The 0:15:01.250,0:15:04.390 three most popular, I want to say, the Randori 0:15:04.390,0:15:07.970 Kata, the Prepared and the Code Retreat, which[br]is 0:15:07.970,0:15:09.760 more like an event, but we're gonna treat[br]it 0:15:09.760,0:15:10.550 as a Kata. 0:15:10.550,0:15:14.170 And the Randori Kata is the most popular for 0:15:14.170,0:15:17.959 meet ups and schools and university. David[br]is a 0:15:17.959,0:15:21.149 teacher at a local university in Orlando,[br]and he 0:15:21.149,0:15:23.890 uses Coding Dojo as part of the curriculum. 0:15:23.890,0:15:26.450 And the way that the Randori works, you have 0:15:26.450,0:15:29.420 one computer, and the code in that computer[br]is 0:15:29.420,0:15:33.290 projected onto a screen, where an audience,[br]between five 0:15:33.290,0:15:34.990 and fifteen people, a little bit more than[br]that 0:15:34.990,0:15:37.269 gets a little bit confusing. So, the audience[br]is 0:15:37.269,0:15:41.870 watching the code, is watching the evolution[br]of the 0:15:41.870,0:15:44.040 code towards the solution all the time. So[br]they're 0:15:44.040,0:15:46.890 constantly, you know, learning things and[br]watching where the 0:15:46.890,0:15:49.019 pair is going with the code. 0:15:49.019,0:15:52.390 And, in the computer, there's always two people[br]pair 0:15:52.390,0:15:55.899 programming. The pilot and the co-pilot. And[br]every three 0:15:55.899,0:15:59.980 to seven minutes, they rotate. So, the driver[br]goes 0:15:59.980,0:16:03.029 back to the audience. The co-pilot becomes[br]the pilot. 0:16:03.029,0:16:06.120 And someone from the audience volunteers to[br]be the 0:16:06.120,0:16:08.230 co-pilot. So that way we have everyone in[br]the 0:16:08.230,0:16:10.880 room collaborating towards learning. 0:16:10.880,0:16:14.240 D.R.: And, and like Carlos was saying, I,[br]I 0:16:14.240,0:16:17.450 used this in my, in my courses at Valencia. 0:16:17.450,0:16:20.930 We, we spend, it's an Introduction to Programming[br]course 0:16:20.930,0:16:23.399 where we spend the first half of the course 0:16:23.399,0:16:26.970 learning the concepts of programming and practicing[br]reading the 0:16:26.970,0:16:30.260 code, reading open source projects, identifying[br]pieces of the 0:16:30.260,0:16:31.990 code that we've talked about, and the second[br]half 0:16:31.990,0:16:34.910 of the class is all these Coding Dojos, these 0:16:34.910,0:16:37.370 Randori-style Coding Dojos. 0:16:37.370,0:16:39.600 Over the, the couple years that we ran the 0:16:39.600,0:16:43.240 Coding Dojo in Orlando, we got a mixed bag 0:16:43.240,0:16:45.620 of folks from all over the spectrum. People[br]that 0:16:45.620,0:16:48.269 had no coding experience all the way up to 0:16:48.269,0:16:50.089 people that had been coding for years and[br]years 0:16:50.089,0:16:53.209 and years and years. And strangely enough,[br]the super 0:16:53.209,0:16:56.070 experts were the ones that were least interested[br]in 0:16:56.070,0:16:57.290 the format. 0:16:57.290,0:16:59.810 But we used it as a method of teaching 0:16:59.810,0:17:05.419 ourselves new tools, new techniques, completely[br]different languages. Our 0:17:05.419,0:17:07.609 first attempt at a Python Coding Dojo was[br]a 0:17:07.609,0:17:10.819 complete dog's breakfast. But we came back,[br]we learned, 0:17:10.819,0:17:12.898 we learned enough Python that now I actually[br]run 0:17:12.898,0:17:16.349 the Python user group in Orlando, and teach[br]other 0:17:16.349,0:17:19.019 people how to use Python and when to use 0:17:19.019,0:17:20.739 Python and that sort of thing. 0:17:20.739,0:17:22.309 We, we taught a bunch of people Ruby. We've 0:17:22.309,0:17:24.409 taught a bunch of people JavaScript, learned[br]that there 0:17:24.409,0:17:26.789 are like seventeen different JavaScript frameworks,[br]and a new 0:17:26.789,0:17:32.179 one every week, to run tests or implement[br]assertions. 0:17:32.179,0:17:33.340 That's always fun. 0:17:33.340,0:17:34.509 But the, the key is, we give them, we 0:17:34.509,0:17:37.470 give everybody a time box and we wait for, 0:17:37.470,0:17:40.429 either everyone gets a chance to code, we[br]solve 0:17:40.429,0:17:42.279 the problem - which very rarely happens - or 0:17:42.279,0:17:44.519 we have it, the entire thing time-boxed to[br]maybe 0:17:44.519,0:17:46.179 a two hour time frame. 0:17:46.179,0:17:47.489 So that really works well for a lot of 0:17:47.489,0:17:49.139 people, like a classroom setting where you[br]know you 0:17:49.139,0:17:52.330 have x number of hours to participate, and[br]you 0:17:52.330,0:17:54.419 have, you know, somewhere between that magic[br]number of 0:17:54.419,0:17:56.399 five to fifteen people so that everyone can[br]get 0:17:56.399,0:17:59.499 a chance to code inside of that two hours. 0:17:59.499,0:18:01.799 C.S.: And one thing worth mentioning, too,[br]is that 0:18:01.799,0:18:03.899 the Randori-style Kata is also a great way[br]to 0:18:03.899,0:18:06.940 interview potential developer candidates.[br]If you want to move 0:18:06.940,0:18:08.769 away from the typical, where do you see yourself 0:18:08.769,0:18:11.350 in five years? And cut that, cut out all 0:18:11.350,0:18:13.190 that bull shit, and get to what matters, which 0:18:13.190,0:18:16.419 is coding and seeing, you know, how efficient[br]your 0:18:16.419,0:18:19.669 developer is, and how willing to pair program,[br]how 0:18:19.669,0:18:21.950 willing to collaborate he is. The Coding Dojo,[br]I 0:18:21.950,0:18:23.549 want to say, is the best way to do 0:18:23.549,0:18:26.470 that, right. Because you're hiring someone[br]to be a 0:18:26.470,0:18:26.799 developer. 0:18:26.799,0:18:29.129 So, sit with them, code with them. Seeing[br]how 0:18:29.129,0:18:32.850 well the fit with the culture, with the pair 0:18:32.850,0:18:35.679 programming culture in your company, or with[br]the development 0:18:35.679,0:18:38.230 style that your company adopts. And we use[br]it 0:18:38.230,0:18:40.239 a lot at Code School and Envy Labs, and 0:18:40.239,0:18:43.639 it's worked out great, I'd say. 0:18:43.639,0:18:46.590 The second type of Kata is the Prepared Kata, 0:18:46.590,0:18:50.999 and that is when you watch perform a, a 0:18:50.999,0:18:54.710 Kata that has been previously worked on. So,[br]David 0:18:54.710,0:18:56.179 and I are gonna show that to you in 0:18:56.179,0:18:58.830 a little bit. We're going to start coding[br]a 0:18:58.830,0:19:02.220 problem from scratch, and we're going to be[br]pair 0:19:02.220,0:19:05.090 programming on that problem. You can either[br]pair program 0:19:05.090,0:19:07.399 or do it solo, but the thing is, you're 0:19:07.399,0:19:11.429 showing people one way to solve the problem,[br]and 0:19:11.429,0:19:14.879 you're showing them, also, a bunch of, of[br]tricks 0:19:14.879,0:19:17.179 that you may use. Perhaps you're showing them[br]how 0:19:17.179,0:19:20.019 to use a different editor that just came out, 0:19:20.019,0:19:22.129 or perhaps you're showing them one feature[br]of an 0:19:22.129,0:19:25.059 existing editor that you might already use.[br]You're showing 0:19:25.059,0:19:28.529 them different API for the language. So there's[br]different, 0:19:28.529,0:19:31.029 there's a multitude of things that you can[br]learn 0:19:31.029,0:19:34.460 by watching someone perform a prepared Kata. 0:19:34.460,0:19:36.869 And lastly. 0:19:36.869,0:19:40.970 D.R.: We, we actually had the, the opportunity[br]to 0:19:40.970,0:19:43.230 have Corey Haines - has anybody heard of Corey 0:19:43.230,0:19:45.379 Haines? If you guys know anything about the[br]Dojo, 0:19:45.379,0:19:48.929 you've probably heard about Corey Haines.[br]Corey Haines, yeah, 0:19:48.929,0:19:53.129 he's local up here. He came down to Orlando 0:19:53.129,0:19:55.789 and gave what he calls a Code Retreat, and 0:19:55.789,0:19:59.909 those are fantastic, all-day events where[br]you get the 0:19:59.909,0:20:02.019 opportunity to pair up with people that you've[br]never 0:20:02.019,0:20:06.139 programmed with before, maybe never seen before.[br]You, everyone 0:20:06.139,0:20:08.279 agrees to solve the same problem. He usually[br]uses 0:20:08.279,0:20:12.159 Conway's Game of Life, which is a wonderfully[br]brain-bending 0:20:12.159,0:20:14.210 program in whatever language you're trying[br]to learn. 0:20:14.210,0:20:17.399 You all pair for thirty minutes or an hour 0:20:17.399,0:20:20.320 or, or whatever the time box is for that 0:20:20.320,0:20:22.629 event. You pair with different people at the[br]end 0:20:22.629,0:20:24.159 of the time box. You're free to switch pairs. 0:20:24.159,0:20:26.609 You're free to switch languages. You're free[br]to try 0:20:26.609,0:20:29.070 a different approach. Add some constraints.[br]Whatever. But you 0:20:29.070,0:20:30.669 agree to do it all day. You have a 0:20:30.669,0:20:32.889 lot of practice and a lot of time. 0:20:32.889,0:20:35.029 That's similar to the format that we're gonna[br]use 0:20:35.029,0:20:38.259 today for the second half, or second two-thirds[br]of 0:20:38.259,0:20:41.090 the seminar. And if you want to know more 0:20:41.090,0:20:44.309 about Corey Haines Code Retreat, or perhaps[br]bug him 0:20:44.309,0:20:46.409 incessantly on Twitter for him to bring a[br]Code 0:20:46.409,0:20:48.729 Retreat to your city, you can find him at 0:20:48.729,0:20:52.229 his horribly ugly website, coderetreat dot[br]org. And on 0:20:52.229,0:20:54.100 the internets as @CoreyHaines. 0:20:54.100,0:20:59.409 C.S.: Cool. So. I think we're good to move 0:20:59.409,0:21:02.139 on to show you guys a Prepared Kata that 0:21:02.139,0:21:08.769 David and I practiced and. Cool. Let's do[br]it. 0:21:08.769,0:21:12.070 Like I said, we're gonna do something that[br]we're 0:21:12.070,0:21:15.489 already worked on. We've previously worked[br]on. And we're 0:21:15.489,0:21:17.909 gonna show you how to implement a very, very, 0:21:17.909,0:21:21.850 very simple calculator. And, and this calculator[br]is going 0:21:21.850,0:21:26.940 to have one operation, which is gonna be addition. 0:21:26.940,0:21:29.859 This operation should be able to accept two[br]numbers 0:21:29.859,0:21:32.169 and return the result. 0:21:32.169,0:21:35.320 Should be simple enough, right? Cool. We're[br]gonna use 0:21:35.320,0:21:38.350 Ruby, Ruby 2 point 0, but if you have 0:21:38.350,0:21:41.830 Ruby 1.9 in your computer, it's fine. And[br]we're 0:21:41.830,0:21:46.539 gonna use miniTest, also known as Test Unit,[br]for 0:21:46.539,0:21:48.629 this, and that's it. We're not gonna use any 0:21:48.629,0:21:52.409 framework. Everything is built into the standard[br]library. 0:21:52.409,0:21:55.009 If you can, you can follow along. Or if 0:21:55.009,0:21:56.950 you just want to watch it, and then try 0:21:56.950,0:21:59.179 to do it on your own after we're done, 0:21:59.179,0:22:01.190 that's fine too. Right. So this is like the 0:22:01.190,0:22:03.559 first Kata that we're gonna run. 0:22:03.559,0:22:07.039 D.R.: And because pairing, because the ping[br]pong style 0:22:07.039,0:22:09.279 pairing is a lot of vocal back and forth, 0:22:09.279,0:22:10.940 we're gonna shove the mic right up here in 0:22:10.940,0:22:12.639 the front, and we'll attempt to talk into[br]it 0:22:12.639,0:22:16.129 as much as possible. So bear with us. If 0:22:16.129,0:22:18.489 you can't hear us, just holler or throw paper 0:22:18.489,0:22:19.149 or something. 0:22:19.149,0:22:22.239 C.S.: And also, if you have any questions,[br]if 0:22:22.239,0:22:23.960 you don't understand anything that we do - we're 0:22:23.960,0:22:26.399 gonna try to explain everything and describe[br]as we 0:22:26.399,0:22:28.700 go, but if you have any questions, please,[br]please, 0:22:28.700,0:22:35.700 please raise your hand and ask us. Don't hesitate. 0:22:37.929,0:22:44.929 So, so far we have an empty file. There's 0:22:46.499,0:22:49.529 nothing on this file. Kata dot rb. And we're 0:22:49.529,0:22:53.489 going to develop a very simple calculator.[br]So I'm 0:22:53.489,0:22:58.029 gonna fire up Vim, open the file. Can everyone 0:22:58.029,0:23:02.200 see? Good? Decent? Cool? All right. So we're[br]going 0:23:02.200,0:23:08.580 to use miniTest, the unit. Because you have[br]miniTest 0:23:08.580,0:23:10.440 unit and you also have miniTest specs. So[br]we're 0:23:10.440,0:23:12.559 gonna do the unit type. 0:23:12.559,0:23:15.029 And, to run our tests, we also have to 0:23:15.029,0:23:21.820 require 'minitest/auto' to automatically run[br]this file. We're gonna 0:23:21.820,0:23:24.239 start with our test case, which is going to 0:23:24.239,0:23:31.239 be CalculatorTest < Minitest::Unit::TestCase.[br]We got our test suite 0:23:35.840,0:23:39.269 class, and we're going to write our first[br]test. 0:23:39.269,0:23:43.830 So test_adds_two_numbers. 0:23:43.830,0:23:46.259 So if we change it and you go to 0:23:46.259,0:23:53.259 that same folder, if we're in Ruby, Kata cannot 0:23:54.769,0:23:55.869 load minitest/auto. 0:23:55.869,0:23:57.259 AUDIENCE: Autorun. 0:23:57.259,0:24:02.720 C.S.: Autorun. Thank you. There you go. Collaborative. 0:24:02.720,0:24:05.509 D.R.: Thank you audience. 0:24:05.509,0:24:08.549 C.S.: Right. So now we got something here.[br]Let 0:24:08.549,0:24:11.590 me add clear. And Ruby Kata. 0:24:11.590,0:24:14.220 D.R.: Tada! 0:24:14.220,0:24:18.940 C.S.: Cool. So that gives us proof that we 0:24:18.940,0:24:21.059 were able to import the correct libraries,[br]we were 0:24:21.059,0:24:23.999 able to create the correct test suite, and[br]that 0:24:23.999,0:24:26.470 Ruby picked it up and it gives us a 0:24:26.470,0:24:29.169 proper error message, or at least a proper[br]message. 0:24:29.169,0:24:30.710 Cause we don't have any assertions yet. So[br]it's 0:24:30.710,0:24:33.940 just saying, hey, we found one test. There's[br]zero 0:24:33.940,0:24:38.369 assertions, zero failures, no errors, and[br]no skips. Right. 0:24:38.369,0:24:41.179 So moving on to the first failing test, I'm 0:24:41.179,0:24:48.039 going to create a local variable, and instantiate[br]an 0:24:48.039,0:24:50.619 object from a class that I want to have, 0:24:50.619,0:24:52.299 but I don't have yet. So I'm gonna let 0:24:52.299,0:24:54.659 my tests tell me what I should do next. 0:24:54.659,0:24:57.169 If I run this again, it's gonna blow up, 0:24:57.169,0:24:57.440 right. 0:24:57.440,0:24:58.859 So I got a failing test. So now I'm 0:24:58.859,0:25:00.820 gonna pass it along to David to solve that 0:25:00.820,0:25:01.009 test. 0:25:01.009,0:25:03.539 D.R.: Yeah. Thanks for leaving me a lovely[br]mess 0:25:03.539,0:25:04.869 there. 0:25:04.869,0:25:06.340 C.S.: That's real life, man. 0:25:06.340,0:25:08.379 D.R.: Yeah. This is a. At least you didn't 0:25:08.379,0:25:12.690 commit it, right? So I'm gonna actually, gonna[br]type 0:25:12.690,0:25:14.879 only the code that I need to fulfill this 0:25:14.879,0:25:16.359 task. And I'm gonna do it right in the 0:25:16.359,0:25:18.840 same file. Some people would split it out,[br]but 0:25:18.840,0:25:21.999 for, for this simple example, we're gonna[br]just do 0:25:21.999,0:25:25.269 exactly what we need. 0:25:25.269,0:25:32.269 And so, if I just define a Calculator, then 0:25:33.460,0:25:38.179 that should, at least, change the error message.[br]And 0:25:38.179,0:25:41.269 it does. Now I have one test. No assertions. 0:25:41.269,0:25:43.029 But I don't have a big giant barf. 0:25:43.029,0:25:45.200 So I'm gonna write a test. This is using 0:25:45.200,0:25:51.289 the ping pong method. Equals or equal? 0:25:51.289,0:25:53.529 C.S.: Equal. 0:25:53.529,0:25:59.190 D.R.: Equal. Of course. I'm gonna add two[br]numbers 0:25:59.190,0:26:06.190 together, say, one and one. All right? Rerun[br]the 0:26:08.570,0:26:11.359 tests. And now I get barf. And so I 0:26:11.359,0:26:14.979 hand it back off to my pair. Ping. 0:26:14.979,0:26:17.769 C.S.: So the error is saying there's an undefined 0:26:17.769,0:26:21.789 method add. So that's simple enough. I'm going[br]to 0:26:21.789,0:26:25.029 come here and define a method add. If I 0:26:25.029,0:26:28.049 run it again, now it's complaining about another[br]thing, 0:26:28.049,0:26:30.479 which is sort of good. If you're doing TDD, 0:26:30.479,0:26:32.989 you want either to make the test pass or 0:26:32.989,0:26:34.970 to make the message change. 0:26:34.970,0:26:37.309 So, this is to ensure that whatever code you're 0:26:37.309,0:26:42.029 writing in your production part is effecting[br]your tests, 0:26:42.029,0:26:45.190 right. Because, I cannot count how many times[br]it 0:26:45.190,0:26:47.619 happened to me in real life, I'm editing a 0:26:47.619,0:26:50.309 file, but it just happens to be a file 0:26:50.309,0:26:52.499 with the same name on a completely different[br]project. 0:26:52.499,0:26:53.210 D.R.: Right. 0:26:53.210,0:26:55.609 C.S.: So I'm editing like a calculated dot[br]rb 0:26:55.609,0:26:57.679 on a different project, and I'm refreshing[br]the browser, 0:26:57.679,0:26:59.989 wondering, what the hell is this not taking[br]effect? 0:26:59.989,0:27:02.090 Right. So when you're doing test-driven development,[br]you want 0:27:02.090,0:27:03.899 to make sure that whatever code you write[br]in 0:27:03.899,0:27:05.999 production, you run the test, so, to make[br]sure 0:27:05.999,0:27:08.289 that your code is taking effect. Right. 0:27:08.289,0:27:10.359 D.R.: Right. And the, the key there is, run 0:27:10.359,0:27:13.229 your tests and observe the expected failure,[br]or at 0:27:13.229,0:27:15.690 least observe that something, the failure[br]has changed. 0:27:15.690,0:27:16.059 C.S.: Right. 0:27:16.059,0:27:17.440 D.R.: That you're, you're having an effect. 0:27:17.440,0:27:20.299 C.S.: So I'm going to save this. Add in 0:27:20.299,0:27:23.059 two arguments. Run the test again. Now it's[br]saying, 0:27:23.059,0:27:25.229 now it's giving us a different message. It's[br]saying 0:27:25.229,0:27:28.599 it expected Nil, but, but it got two. So, 0:27:28.599,0:27:30.629 I'm reading this, and I'm thinking. Well that's,[br]that's, 0:27:30.629,0:27:33.429 that's kind of weird. I'm not expecting Nil.[br]I 0:27:33.429,0:27:35.429 should be expecting two. 0:27:35.429,0:27:37.580 So that leads me to the conclusion that maybe 0:27:37.580,0:27:42.519 we passed the wrong order to our assert method. 0:27:42.519,0:27:47.239 So to go back, here, assert_equal is very[br]strict 0:27:47.239,0:27:50.409 about the order of arguments. So we can produce 0:27:50.409,0:27:53.019 the best error message for you. So what we 0:27:53.019,0:27:57.960 should do here, instead, is put two calculator.add[br]one 0:27:57.960,0:28:00.460 and one. And when we do that and then 0:28:00.460,0:28:01.969 we run our tests again, we can see that 0:28:01.969,0:28:04.749 now the error message is, it makes more sense, 0:28:04.749,0:28:07.989 right. It expected two but it actually got[br]Nil. 0:28:07.989,0:28:10.570 Now, it's time to write the simplest thing[br]that 0:28:10.570,0:28:13.859 could possibly make this work. And will probably[br]make 0:28:13.859,0:28:20.539 your skin crawl. Is to return two. Cool. So 0:28:20.539,0:28:23.269 now we have one test and one assertion. Now 0:28:23.269,0:28:25.719 it's time for me to write a test, a 0:28:25.719,0:28:28.609 failing test, or David to fulfill. 0:28:28.609,0:28:35.609 Equal. Seven. Five and two. So I'm gonna do 0:28:37.669,0:28:39.349 AUDIENCE: Could that also lead you to splitting[br]the 0:28:39.349,0:28:46.039 two tests out of this matter? 0:28:46.039,0:28:52.190 C.S.: Say that again. 0:28:52.190,0:28:52.940 AUDIENCE: Will you, should you be splitting[br]the two 0:28:52.940,0:28:53.599 tests into two assertions. Two assertions,[br]two tests. 0:28:53.599,0:28:54.519 C.S.: That is a good point. I do that 0:28:54.519,0:28:58.210 when I'm talking about different features,[br]right. So there's, 0:28:58.210,0:28:59.529 it's really up to you how fine-grained you[br]want 0:28:59.529,0:29:00.219 to get. Because we're testing, if you look[br]at 0:29:00.219,0:29:00.909 the name of the test method, the test_that_adds_two_numbers.[br]So 0:29:00.909,0:29:07.909 those two assertions, they still belong to[br]that idea, 0:29:08.609,0:29:11.789 to that context of adding two numbers. 0:29:11.789,0:29:14.779 D.R.: Right. And we, we talk about the granularity 0:29:14.779,0:29:17.820 of testing, just simple assertion testing[br]which is what 0:29:17.820,0:29:19.820 we're doing with assert_equal or any of the[br]assert 0:29:19.820,0:29:22.690 methods. That's like the smallest little piece[br]of a 0:29:22.690,0:29:24.979 test. That's the tiniest little piece of a[br]test. 0:29:24.979,0:29:28.539 We then compose those assertions together[br]into the unit, 0:29:28.539,0:29:30.399 and the unit, in this case, like Kaikay had 0:29:30.399,0:29:32.570 described, is just that we can add two numbers. 0:29:32.570,0:29:35.460 There might be multiple assertions that describe[br]how we 0:29:35.460,0:29:37.429 can add two numbers, and as we go through 0:29:37.429,0:29:39.239 the example we'll see that, and we'll start[br]to 0:29:39.239,0:29:42.289 break out, what happens if we give it three 0:29:42.289,0:29:42.719 numbers? 0:29:42.719,0:29:46.009 C.S.: And that's when we break into another[br]test. 0:29:46.009,0:29:49.960 D.R.: Right. Does that answer your question?[br]More or 0:29:49.960,0:29:50.969 less? All right. Great. 0:29:50.969,0:29:53.749 So, I've got this busted up test sitting in 0:29:53.749,0:29:57.779 front of me. So the simplest thing that I 0:29:57.779,0:30:01.149 could possibly do is, I'm gonna go ahead and 0:30:01.149,0:30:07.070 do some math. Actually do some work here.[br]Buddy. 0:30:07.070,0:30:09.799 And now I've got passing tests. But I sort 0:30:09.799,0:30:12.679 of see, already, that Calculator is gonna[br]be a 0:30:12.679,0:30:15.729 whole lot to type. So I'm gonna take a 0:30:15.729,0:30:19.960 minute and just refactor. Rather than typing[br]calculator all 0:30:19.960,0:30:22.929 the dang time, why don't we change this to 0:30:22.929,0:30:25.869 just, like, calc? That's still descriptive[br]of what the 0:30:25.869,0:30:32.869 object is, but it's a lot less repetitive. 0:30:34.059,0:30:37.239 So I make my couple of changes to refactor, 0:30:37.239,0:30:41.599 and then I rerun the tests. And boy, it'd 0:30:41.599,0:30:43.849 be nice if these, if these tests were a 0:30:43.849,0:30:45.169 little prettier. But I'll leave that to another,[br]to 0:30:45.169,0:30:46.039 another person. 0:30:46.039,0:30:50.509 Now, what do you think? We've got, we've got 0:30:50.509,0:30:52.119 the ability to add two numbers. Should we[br]add 0:30:52.119,0:30:54.619 some more two numbers? Or do you, maybe we 0:30:54.619,0:30:57.739 can move on? Maybe we'll move on and get 0:30:57.739,0:30:58.349 a little more complicated. 0:30:58.349,0:30:59.450 C.S.: Yeah. Let's do that. 0:30:59.450,0:31:05.029 D.R.: So yeah. Why don't we write another[br]test? 0:31:05.029,0:31:07.320 And this time, I'll, I'll throw you a curve 0:31:07.320,0:31:13.809 ball. You can add three numbers. Now we're[br]getting 0:31:13.809,0:31:20.809 fancy. So, if I, if I expect nine, three 0:31:21.489,0:31:26.749 and three and three, should add up to nine. 0:31:26.749,0:31:28.809 But should be clearly, clear, that I'm gonna[br]need 0:31:28.809,0:31:32.029 to do some copy pasta here. Which is a 0:31:32.029,0:31:34.479 great opportunity to refactor, of course. 0:31:34.479,0:31:39.659 But I feel like making Kaikay work. Look at 0:31:39.659,0:31:44.659 that. Ping pong, sir. 0:31:44.659,0:31:50.529 C.S.: Cool. So. Says the number, wrong number[br]of 0:31:50.529,0:31:52.599 arguments. It took three but it was only expecting 0:31:52.599,0:31:55.279 two. So, I'm gonna write the simplest thing[br]that 0:31:55.279,0:31:59.969 could possibly work, or change this message,[br]right. So 0:31:59.969,0:32:02.799 what I'm gonna do is add another argument.[br]But 0:32:02.799,0:32:05.820 if I simply add another argument, then I made 0:32:05.820,0:32:07.710 that test pass but I make the other ones 0:32:07.710,0:32:07.950 fail. 0:32:07.950,0:32:09.879 Cause, if I look at the error message. 0:32:09.879,0:32:11.519 D.R.: If you could look at the error message. 0:32:11.519,0:32:14.589 C.S.: If I could look at the error message. 0:32:14.589,0:32:16.330 D.R.: The little green. 0:32:16.330,0:32:17.639 C.S.: What's that? 0:32:17.639,0:32:20.419 D.R.: It's too tall. The window's too tall. 0:32:20.419,0:32:22.529 C.S.: Is it? Right. All right. So, if you 0:32:22.529,0:32:24.979 can see here, now I broke the other ones. 0:32:24.979,0:32:27.609 So what I'm going to do is actually make. 0:32:27.609,0:32:30.769 Let me fix my window. Is actually make this 0:32:30.769,0:32:35.450 third one optional. If I run it again, now 0:32:35.450,0:32:37.419 I don't have a syntax error anymore. Now I 0:32:37.419,0:32:39.960 have an assertion error. Which, again, is[br]good, right. 0:32:39.960,0:32:41.229 D.R.: Man it would be nice if we could 0:32:41.229,0:32:46.009 see the differences there. That, that white[br]text on 0:32:46.009,0:32:47.710 a white back- on a, on a black background 0:32:47.710,0:32:48.259 is particularly- 0:32:48.259,0:32:49.379 C.S.: You're right. I wonder if we can make 0:32:49.379,0:32:50.059 this colored, right. 0:32:50.059,0:32:52.379 D.R.: I wondered. If we could make this prettier. 0:32:52.379,0:32:56.690 C.S.: So let's go ahead and add require 'minitest/bright' 0:32:56.690,0:32:59.729 and make our tests fabulous. So now you can 0:32:59.729,0:33:01.809 see, down at the bottom here, that we have 0:33:01.809,0:33:03.759 a little column. Might not be able to see 0:33:03.759,0:33:05.989 it clearly on the projector, but it does make 0:33:05.989,0:33:07.499 a lot of difference when you're look at your 0:33:07.499,0:33:08.259 terminal, right. 0:33:08.259,0:33:09.599 D.R.: You get a nice big red F. 0:33:09.599,0:33:13.019 C.S.: So, the big F is saying that expected 0:33:13.019,0:33:15.279 nine, but it got six. So I'm gonna go 0:33:15.279,0:33:21.580 ahead and add C to make it pass. Cool. 0:33:21.580,0:33:24.339 And because I don't like reading a lot, I'm 0:33:24.339,0:33:27.749 just gonna remove return, because Ruby automatically[br]returns the 0:33:27.749,0:33:30.629 last expression of the method. So I'm gonna[br]run 0:33:30.629,0:33:35.799 this again, and now all my tests pass, right. 0:33:35.799,0:33:37.429 Cool. 0:33:37.429,0:33:39.580 Let's see what we can do now. Should we 0:33:39.580,0:33:43.029 add more numbers? So we can refactor this[br]whole 0:33:43.029,0:33:43.080 thing? 0:33:43.080,0:33:43.179 D.R.: Yeah. 0:33:43.179,0:33:43.499 C.S.: What do you think? 0:33:43.499,0:33:44.289 D.R.: Let's do, let's do one more, one more 0:33:44.289,0:33:45.059 test. 0:33:45.059,0:33:48.070 C.S.: So, I don't want you to cheat, cause 0:33:48.070,0:33:50.719 I don't want you to keep adding single arguments. 0:33:50.719,0:33:57.279 I'm just gonna add five numbers, right. So[br]I'm 0:33:57.279,0:34:00.289 gonna copy and paste this, and copying and[br]pasting 0:34:00.289,0:34:04.029 never resulted in any error, ever. And, it's[br]gonna- 0:34:04.029,0:34:07.690 D.R.: It certainly results in highly maintainable[br]code. 0:34:07.690,0:34:13.330 C.S.: Twenty-five. Five, five, five, five,[br]five. 0:34:13.330,0:34:16.339 D.R.: You can tell we're mathematicians as[br]well, right. 0:34:16.339,0:34:18.690 Neither one of us aspire to computer science. 0:34:18.690,0:34:22.270 C.S.: Cool. So now you got one more. 0:34:22.270,0:34:26.929 D.R.: Dun, dun, duh! So. Back again we go. 0:34:26.929,0:34:28.540 The simplest thing that I could possibly do[br]is 0:34:28.540,0:34:31.520 add five, and a bunch of, and a bunch 0:34:31.520,0:34:34.960 of junk inside my add method. But that seems, 0:34:34.960,0:34:41.960 well, stupid. So, let's, instead, just replace. 0:34:42.860,0:34:47.870 C.S.: Hello? Is that a duck? Duck face? 0:34:47.870,0:34:51.080 D.R.: There we go. 0:34:51.080,0:34:52.679 C.S.: nice. 0:34:52.679,0:34:59.060 D.R.: Let's instead replace this with a splat.[br]That's 0:34:59.060,0:35:03.270 my favorite. And that should get rid of my 0:35:03.270,0:35:06.520 wrong arguments error. Oh god. But I got a 0:35:06.520,0:35:10.630 whole bunch. And you know what, this, this[br]running 0:35:10.630,0:35:12.480 this test thing's getting kind of tedious.[br]I don't 0:35:12.480,0:35:15.400 like flipping back and forth between the windows.[br]Is 0:35:15.400,0:35:16.470 there a way we could automate that? 0:35:16.470,0:35:17.060 C.S.: I wonder. 0:35:17.060,0:35:19.410 D.R.: I wonder. Well, I'm more of a, a 0:35:19.410,0:35:22.240 bash-y person than most, so, in. 0:35:22.240,0:35:25.520 C.S.: So we could add auto-watch if we really 0:35:25.520,0:35:27.700 wanted to add a dependency and all that stuff, 0:35:27.700,0:35:27.800 right. 0:35:27.800,0:35:29.310 D.R.: Oh, right. And download a gem or, you 0:35:29.310,0:35:31.860 know, we know our way around Grunt. I'm more 0:35:31.860,0:35:33.950 of a JavaScript guy than a Ruby guy, so 0:35:33.950,0:35:34.510 I know way more- 0:35:34.510,0:35:35.770 D.C.: Dude, haven't you heard? Gulp is the[br]new 0:35:35.770,0:35:35.910 Grunt. 0:35:35.910,0:35:37.420 D.R.: Oh, right. And so, and then followed[br]by 0:35:37.420,0:35:42.110 Guzzle and, and Yak, I think is coming eventually, 0:35:42.110,0:35:44.820 right. We could do all that and wait through 0:35:44.820,0:35:46.990 like fifteen minutes of downloading stuff.[br]But I, I 0:35:46.990,0:35:48.750 know bash really well, so I'm just gonna write 0:35:48.750,0:35:55.750 myself a wonderful infinite loop. But I'll[br]add a 0:35:57.930,0:36:01.810 sleep. So that I don't blow my stack out. 0:36:01.810,0:36:03.420 And now every two seconds or so, it's going 0:36:03.420,0:36:05.930 to run, rerun the tests, rerun the tests,[br]rerun 0:36:05.930,0:36:07.080 the tests. And I never have to touch that 0:36:07.080,0:36:08.300 window again. Thank you very much. 0:36:08.300,0:36:09.020 AUDIENCE: [indecipherable] 0:36:09.020,0:36:10.090 C.S.: What's that? 0:36:10.090,0:36:10.810 AUDIENCE: [indecipherable] 0:36:10.810,0:36:11.880 D.R.: Oh, sure. 0:36:11.880,0:36:15.110 C.S.: Oh, the code for the, yeah. The bash. 0:36:15.110,0:36:16.510 D.R.: So it's just a simple- 0:36:16.510,0:36:18.830 AUDIENCE: [chatter] 0:36:18.830,0:36:25.830 D.R.: Oh, lame. Lame. Pretty simple. Here,[br]let's. Let's 0:36:29.270,0:36:35.310 do this. So, pretty simple bash infinite loop.[br]While 0:36:35.310,0:36:38.700 true, run the tests. Sleep for two. If we 0:36:38.700,0:36:41.970 really wanted to make it even, even closer[br]to 0:36:41.970,0:36:45.500 what Kaikay typed last, we'll do a clear.[br]And 0:36:45.500,0:36:49.320 while I run that, every two seconds it's going 0:36:49.320,0:36:51.660 to refresh the screen and rerun the tests[br]for 0:36:51.660,0:36:55.840 me. That is the poor-man's file-watcher. That's[br]just in 0:36:55.840,0:36:58.510 case you're running free BSD or a clone thereof 0:36:58.510,0:37:03.070 and do not have watch installed by default. 0:37:03.070,0:37:04.670 So now the simplest thing that I could possibly 0:37:04.670,0:37:07.940 do here is numbers. Now, if this was JavaScript 0:37:07.940,0:37:11.220 I would probably use reduce on this array,[br]but 0:37:11.220,0:37:13.280 this isn't JavaScript. So what is it in, in 0:37:13.280,0:37:14.010 Ruby? 0:37:14.010,0:37:15.470 AUDIENCE: Inject. 0:37:15.470,0:37:22.070 D.R.: Inject? Reduce? Oh, look. You steered[br]me wrong. 0:37:22.070,0:37:24.340 And so, reduce is gonna take, does it take 0:37:24.340,0:37:26.030 the same arguments? 0:37:26.030,0:37:29.390 AUDIENCE: The first argument's the seed. 0:37:29.390,0:37:32.050 D.R.: Right. So I take the seed. And then 0:37:32.050,0:37:34.970 I give it a block. And so then I 0:37:34.970,0:37:40.490 have my, my value and my number. 0:37:40.490,0:37:46.690 C.S.: You might have to use params. I don't 0:37:46.690,0:37:47.000 know. 0:37:47.000,0:37:48.440 D.R.: I don't know. Let's, let's find out. 0:37:48.440,0:37:49.070 C.S.: Yeah. Let's find out. 0:37:49.070,0:37:50.330 D.R.: Find out what happens, right. So we[br]give 0:37:50.330,0:37:52.980 it a block, and then we'll just return v 0:37:52.980,0:37:57.170 plus n, from the block. Write the file and 0:37:57.170,0:37:57.170 D.R.: Yeah. 0:38:05.910,0:38:12.380 passing a block. 0:38:12.380,0:38:16.700 D.R.: Oops. 0:38:16.700,0:38:19.830 And the best part is, I never have to 0:38:19.830,0:38:22.480 touch this dang test file again. He just keeps 0:38:22.480,0:38:25.410 running my tests. So now I've got a, I've 0:38:25.410,0:38:27.660 got a reduce function that works for an infinite 0:38:27.660,0:38:29.990 number of numbers. And I'm back to green tests. 0:38:29.990,0:38:31.590 And I, I've already noticed, you know, let's[br]just, 0:38:31.590,0:38:34.240 let's go ahead and make this guy a little 0:38:34.240,0:38:34.760 bigger. 0:38:34.760,0:38:38.130 I've already noticed that, I've got all this[br]repetition 0:38:38.130,0:38:40.420 in here, right. I've got calc equals, calc[br]equals, 0:38:40.420,0:38:42.910 calc equals. Oh god. So, let's reduce some[br]of 0:38:42.910,0:38:44.200 that repetition. 0:38:44.200,0:38:47.710 C.S.: Reduce? That. 0:38:47.710,0:38:50.100 D.R.: He's a funny guy. 0:38:50.100,0:38:53.860 AUDIENCE: Trying to inject a little humor. 0:38:53.860,0:38:56.540 D.R.: Ha. Ha. Ha. Ha. 0:38:56.540,0:38:59.230 C.S.: Nice. I liked that. 0:38:59.230,0:39:02.810 D.R.: So I'll, I'll add a little set up 0:39:02.810,0:39:09.810 method. Get rid of all those. Oops. Do a 0:39:13.280,0:39:20.280 little find and replace. Rerun. Hey, everything's[br]still passing. 0:39:22.490,0:39:24.920 C.S.: Cool. 0:39:24.920,0:39:29.690 D.R.: Groovy, groovy. Should we go further?[br]Or, I 0:39:29.690,0:39:31.810 mean, I think we've, we've pretty much added[br]as 0:39:31.810,0:39:33.470 many numbers as we can possibly add. We could 0:39:33.470,0:39:37.060 add additional tests, or refactor this test[br]to say, 0:39:37.060,0:39:38.370 adds an infinite number of tes- or, numbers. 0:39:38.370,0:39:38.680 C.S.: Mhmm. 0:39:38.680,0:39:40.640 D.R.: And throw it all kinds of different[br]numbers 0:39:40.640,0:39:43.950 inside of there. Or we could go do something, 0:39:43.950,0:39:45.930 something completely crazy and totally off[br]the spec. 0:39:45.930,0:39:46.420 C.S.: We could. 0:39:46.420,0:39:47.170 D.R.: What else? 0:39:47.170,0:39:49.490 C.S.: What if we added arguments, instead[br]of numbers, 0:39:49.490,0:39:50.930 as strings? Would that work? 0:39:50.930,0:39:52.080 D.R.: Ah, I see. 0:39:52.080,0:39:54.490 C.S.: Does Ruby automatically convert, like,[br]each b would 0:39:54.490,0:39:56.470 do? 0:39:56.470,0:39:59.910 AUDIENCE: Is Ruby as good as PHP? 0:39:59.910,0:40:02.530 D.R.: Is Ruby as good as PHP? 0:40:02.530,0:40:04.410 AUDIENCE: I'll write that down. 0:40:04.410,0:40:08.250 D.R.: Test. Ruby as good as PHP. 0:40:08.250,0:40:10.200 So what should, what, what would we expect[br]it 0:40:10.200,0:40:13.150 to equal? If we do a calc dot add, 0:40:13.150,0:40:17.750 say, one and banana. What should we reason[br]we 0:40:17.750,0:40:19.390 expect this to, to return to us? 0:40:19.390,0:40:21.830 C.S.: So that would probably generate an error,[br]right. 0:40:21.830,0:40:22.970 D.R.: I would expect so. 0:40:22.970,0:40:24.630 C.S.: So what if, instead of banana, we pass 0:40:24.630,0:40:28.160 number two as a string. 0:40:28.160,0:40:31.170 D.R.: Sure. That seems reasonably. I mean,[br]Ruby should 0:40:31.170,0:40:33.520 be able to convert a string with a numeric 0:40:33.520,0:40:34.030 value, right. 0:40:34.030,0:40:36.850 C.S.: So that should equal three integer,[br]right. 0:40:36.850,0:40:41.200 D.R.: Let's see. Oh. Oh. String can't be coerced 0:40:41.200,0:40:45.780 into fixnum? That sounds wonderful. And I'll[br]let you 0:40:45.780,0:40:48.130 take over from there. 0:40:48.130,0:40:51.630 C.S.: Cool. 0:40:51.630,0:40:56.370 So, Ruby has a, a method. I'm not sure 0:40:56.370,0:40:59.700 if it's. I believe it's injected into object.[br]It's 0:40:59.700,0:41:02.300 extended. It's in a part of object, which[br]is 0:41:02.300,0:41:04.740 to_i, right, which is gonna try to convert[br]whatever 0:41:04.740,0:41:07.260 that object is into an integer. So, in this 0:41:07.260,0:41:11.220 case, we're converting the string two into[br]an integer. 0:41:11.220,0:41:14.610 And that made our test pass. 0:41:14.610,0:41:14.830 But now. 0:41:14.830,0:41:16.490 D.R.: But then we get back to that banana 0:41:16.490,0:41:17.600 that I was trying to throw you earlier. 0:41:17.600,0:41:20.030 C.S.: Yeah. So here's the thing. We're looking[br]at 0:41:20.030,0:41:21.900 the test, at the name of the method. Test 0:41:21.900,0:41:24.370 adds string, right. But we want to be a 0:41:24.370,0:41:27.970 little bit more specific about what that does,[br]right. 0:41:27.970,0:41:32.250 So I'm gonna rename this method to test parses 0:41:32.250,0:41:33.710 valid strings. 0:41:33.710,0:41:37.800 And I'm gonna write another test that says[br]test 0:41:37.800,0:41:44.800 raises error for invalid strings, which kind[br]of, kind 0:41:45.080,0:41:48.200 of gives us a bit of a path of 0:41:48.200,0:41:50.920 where we're going with implementing this test,[br]this test 0:41:50.920,0:41:52.690 method. So what we want to do, we'll make 0:41:52.690,0:41:56.100 sure that it raises an, I believe this is 0:41:56.100,0:41:56.380 in the- 0:41:56.380,0:41:56.550 D.R.: Yup. 0:41:56.550,0:42:00.570 C.S.: -in the plural, an argument error, and[br]then 0:42:00.570,0:42:04.640 we'd pass it a block. If we pass it 0:42:04.640,0:42:10.760 an invalid argument. So in this case, a banana. 0:42:10.760,0:42:13.740 Kaboom. 0:42:13.740,0:42:18.080 D.R.: So that brings us back to our original 0:42:18.080,0:42:23.250 question, what is the numeric value of banana,[br]right? 0:42:23.250,0:42:24.980 Apparently to_i is not working the way we[br]expect 0:42:24.980,0:42:27.530 it to. Or, at least, Ruby's doing something[br]with 0:42:27.530,0:42:28.830 it. It's definitely not throwing an error. 0:42:28.830,0:42:29.190 C.S.: Right. 0:42:29.190,0:42:32.000 D.R.: So maybe we should figure out what the 0:42:32.000,0:42:34.460 numeric value of banana is. 0:42:34.460,0:42:35.820 C.S.: Right. 0:42:35.820,0:42:37.260 D.R.: One way we could do that is to 0:42:37.260,0:42:39.850 write a test for it, right. We could write 0:42:39.850,0:42:42.420 an expectation. We expect x to be. Yeah. 0:42:42.420,0:42:45.160 AUDIENCE: [indecipherable] Would it be easier[br]to see? 0:42:45.160,0:42:47.890 C.S.: Do you want me to do that? 0:42:47.890,0:42:49.620 D.R.: Yeah. Use your magic fingers. 0:42:49.620,0:42:52.980 C.S.: If you want, you could do. 0:42:52.980,0:42:54.910 AUDIENCE: That doesn't work? 0:42:54.910,0:42:57.790 D.R.: I don't think that helped. 0:42:57.790,0:42:58.750 C.S.: Yeah. 0:42:58.750,0:42:59.240 AUDIENCE: ?? 0:42:59.240,0:43:02.660 C.S.: Should I make this one bigger and this 0:43:02.660,0:43:03.420 one smaller? 0:43:03.420,0:43:05.500 D.R.: Yeah, we can. I mean, the tests. We 0:43:05.500,0:43:12.500 can even make the font size on the tests 0:43:15.800,0:43:16.050 smaller. 0:43:16.050,0:43:17.020 C.S.: Does that help? 0:43:17.020,0:43:17.760 AUDIENCE: Yeah. Thanks. 0:43:17.760,0:43:18.730 C.S.: All right. Cool. 0:43:18.730,0:43:19.900 D.R.: So now we're stuck with this, you know, 0:43:19.900,0:43:22.350 what is the numeric value of, of, banana.[br]And- 0:43:22.350,0:43:23.140 C.S.: So, yeah. 0:43:23.140,0:43:25.190 D.R.: -I would approach it by writing a test 0:43:25.190,0:43:32.190 for it. Test numeric. Numberic. Numberic.[br]Numeric value of 0:43:33.210,0:43:37.370 banana. That's a drinking game actually. Every[br]time a 0:43:37.370,0:43:43.850 presenter says banana you have to take a drink. 0:43:43.850,0:43:48.230 I, I would expect banana to raise an ex- 0:43:48.230,0:43:50.420 an exception if I tried to coerce it to 0:43:50.420,0:43:52.250 an integer. But, apparently Ruby's doing something[br]else with 0:43:52.250,0:43:54.700 that. So maybe it gives it a value of 0:43:54.700,0:43:56.510 zero. Maybe it's trying to turn it into a 0:43:56.510,0:43:59.280 number. I know another language that begins[br]with a 0:43:59.280,0:44:00.800 P and ends with a P that does something 0:44:00.800,0:44:05.330 similar that confounds many people. 0:44:05.330,0:44:07.100 And we'll use that same to_i trick that you 0:44:07.100,0:44:10.610 just showed me. And let's see what happens.[br]Oh. 0:44:10.610,0:44:12.320 I get a passing test. 0:44:12.320,0:44:13.280 C.S.: Yup. 0:44:13.280,0:44:16.400 D.R.: So. Let's, just to verify, I'll make[br]this 0:44:16.400,0:44:19.160 another value. Like one. Maybe the value of[br]banana 0:44:19.160,0:44:24.700 is one. Nope. The actual value is zero. And, 0:44:24.700,0:44:28.010 interesting thing there, you can see that[br]the, the 0:44:28.010,0:44:30.250 tests are flipping every time we run it, because 0:44:30.250,0:44:35.790 it's implemented as a hash and not. Fun stuff. 0:44:35.790,0:44:38.900 So then if the, if, if the numeric value 0:44:38.900,0:44:45.830 of, of banana is zero, how are we gonna 0:44:45.830,0:44:47.810 test- how are we gonna figure out that we've 0:44:47.810,0:44:51.380 been given a banana instead of a number inside 0:44:51.380,0:44:52.980 of our calculator? 0:44:52.980,0:44:57.160 Well, we could start with a little refactor,[br]right. 0:44:57.160,0:44:59.130 We're probably gonna need some code inside[br]of this 0:44:59.130,0:45:01.470 block. And we run into a number, an argument 0:45:01.470,0:45:04.110 that we've been given that isn't numerically,[br]isn't a 0:45:04.110,0:45:10.160 numericalized varia- or, value. Something[br]that we can coerce. 0:45:10.160,0:45:16.260 Then, we need to do something different. 0:45:16.260,0:45:23.260 So, we'll put a little guard in there. Because 0:45:25.960,0:45:32.150 we want to raise an exception, according to[br]Carlos's 0:45:32.150,0:45:34.810 test. And. 0:45:34.810,0:45:38.850 C.S.: So the reason behind this is, we, we 0:45:38.850,0:45:41.940 realized that if we pass a valid string that 0:45:41.940,0:45:44.280 is able to be parsed to a number, say 0:45:44.280,0:45:45.530 one, in double quotes- 0:45:45.530,0:45:47.080 Or. So. 0:45:47.080,0:45:52.470 D.R.: Just take it. Just take it. 0:45:52.470,0:45:54.570 C.S.: So if you pass a string that is 0:45:54.570,0:45:57.430 able to be converted to an integer, right,[br]say, 0:45:57.430,0:46:00.580 one in quotes, it's successfully converted[br]into one integer. 0:46:00.580,0:46:02.830 But if we pass a string that's not able 0:46:02.830,0:46:04.570 to be converted to an integer, it's gonna[br]resolve 0:46:04.570,0:46:08.190 to zero. So, what we realize is that, the 0:46:08.190,0:46:13.170 valid argument would be if n dash to_i equals 0:46:13.170,0:46:17.120 zero, and at the same time, if the original 0:46:17.120,0:46:20.250 string was zero, then that's a valid one.[br]Otherwise, 0:46:20.250,0:46:22.930 raise an error. So the only reason, the only 0:46:22.930,0:46:25.830 way that it's a valid conversion is if the 0:46:25.830,0:46:30.670 integer zero came from a string zero. 0:46:30.670,0:46:32.330 That's what that code means. 0:46:32.330,0:46:39.330 AUDIENCE: Is there a reason why you're using[br]triple 0:46:41.650,0:46:42.690 equals? 0:46:42.690,0:46:49.690 D.R.: Because I'm a JavaScript guy, and my[br]brain 0:46:52.010,0:46:54.700 is programmed to use triple equals any time[br]I 0:46:54.700,0:46:55.570 compare to zero. I'm sure is something my[br]fingers 0:46:55.570,0:46:56.440 are trained to type. Oh, you're gonna type[br]a 0:46:56.440,0:46:57.310 zero now, aren't you? Let me just throw another 0:46:57.310,0:46:57.690 equal sign in there. 0:46:57.690,0:46:58.510 So yeah. Like, like Carlos was saying. If[br]the 0:46:58.510,0:47:00.960 number what I'm given converts to zero, the[br]number 0:47:00.960,0:47:03.060 that I'm given converts to zero but it isn't 0:47:03.060,0:47:05.910 actually string zero, then that would be one[br]of 0:47:05.910,0:47:08.540 those strings that coerces to zero for us.[br]Thank 0:47:08.540,0:47:09.750 you banana. 0:47:09.750,0:47:10.540 Yeah? 0:47:10.540,0:47:13.690 AUDIENCE: If you, if you coerce it to a 0:47:13.690,0:47:18.090 string that's the same as itself, as an alternative? 0:47:18.090,0:47:19.690 D.R.: Taking, what, sorry? 0:47:19.690,0:47:22.520 AUDIENCE: Take, take, take whatever comes[br]in, and coerce 0:47:22.520,0:47:24.470 it to string, and test whether it's the same 0:47:24.470,0:47:29.210 as itself. If it is, then it's a literal. 0:47:29.210,0:47:31.170 It's a, it's a string. 0:47:31.170,0:47:34.950 D.R.: So, same as that? 0:47:34.950,0:47:36.820 AUDIENCE: Well, you got. I don't mean in the 0:47:36.820,0:47:38.160 second bit. Yeah. 0:47:38.160,0:47:39.680 D.R.: Let's see. 0:47:39.680,0:47:42.220 C.S.: Doesn't look like it. 0:47:42.220,0:47:43.750 D.R.: Apparently not. 0:47:43.750,0:47:46.290 AUDIENCE: Valid strings are failing. 0:47:46.290,0:47:47.300 C.S.: Yeah. 0:47:47.300,0:47:54.300 D.R.: Right. Now valid strings are failing. 0:47:55.130,0:47:56.800 But that's the beauty, again, of the Dojo.[br]If 0:47:56.800,0:47:58.480 there's something that I want to experiment[br]with, I'm, 0:47:58.480,0:48:01.350 I'm at green tests. I can try something else. 0:48:01.350,0:48:03.220 Just, just to see, how does Ruby behave this 0:48:03.220,0:48:03.870 way? 0:48:03.870,0:48:06.470 C.S.: Right. All right. 0:48:06.470,0:48:08.830 So, we're gonna take a little break. So you 0:48:08.830,0:48:09.440 all can. 0:48:09.440,0:48:11.700 D.R.: Yeah. Project Euler is a great- if,[br]if 0:48:11.700,0:48:15.990 you don't know about Project Euler, spelled[br]e-u-l-e-r, Euler. 0:48:15.990,0:48:22.990 Euler. Euler. Hello. ProjectEuler dot net[br]has a ton 0:48:24.120,0:48:29.660 of, of computer science problems that seem[br]trivial at 0:48:29.660,0:48:32.030 first, but if you implement them in the most 0:48:32.030,0:48:35.070 trivial manner possible, you'll do something[br]silly like blow 0:48:35.070,0:48:37.410 out your recursion stack or take an hour and 0:48:37.410,0:48:39.730 a half to compute the result or something[br]like 0:48:39.730,0:48:40.990 that. So you have to think about them a 0:48:40.990,0:48:41.690 little more. 0:48:41.690,0:48:44.730 But, you can do it in a test-driven style, 0:48:44.730,0:48:48.010 and, and once you get passing tests on your 0:48:48.010,0:48:52.330 hour and a half long solution, then optimize,[br]refactor, 0:48:52.330,0:48:54.830 and get a more optimal solution. Figure, there's[br]lots 0:48:54.830,0:48:59.580 of prime number calculations inside of Project[br]Euler. Euler. 0:48:59.580,0:49:02.490 Euler. You'll never forget that now. 0:49:02.490,0:49:05.870 Code Wars is another. That's, that website[br]launched recently. 0:49:05.870,0:49:08.210 CodeWars dot com. You can sign up for JavaScript, 0:49:08.210,0:49:11.600 CoffeeScript and Ruby, I think right now.[br]They've got 0:49:11.600,0:49:13.900 a bunch of Code Katas. They even call them 0:49:13.900,0:49:16.910 Code Katas. You get different belts starting[br]from 8kyu 0:49:16.910,0:49:20.020 and work your way up to Grand Master Black 0:49:20.020,0:49:24.880 Belt. CodeWars dot com. I, I recommend that[br]to 0:49:24.880,0:49:29.250 my students as well. And it's, again, emphasizing[br]test-driven. 0:49:29.250,0:49:31.220 You totally don't have to do it test-driven,[br]but 0:49:31.220,0:49:33.470 it's a great way to practice. 0:49:33.470,0:49:35.120 There are, there are books on the subject,[br]which 0:49:35.120,0:49:36.600 we'll talk about at the end of our presentation. 0:49:36.600,0:49:37.640 There's a great book by- 0:49:37.640,0:49:43.700 C.S.: Emily Clark, if I remember correctly. 0:49:43.700,0:49:48.900 D.R.: Navigata. Bam. Coding Dojo Handbook. 0:49:48.900,0:49:52.360 C.S.: Emily Bache. Yeah. 0:49:52.360,0:49:59.360 D.R.: Forward by Uncle Bob. Rob Martin. So,[br]this 0:49:59.480,0:50:00.910 has a lot of Katas in it, a lot 0:50:00.910,0:50:04.630 of very standard Katas. What we found in running 0:50:04.630,0:50:07.740 the Coding Dojo for a great, for, for two 0:50:07.740,0:50:09.340 years, two plus years at that point, was that 0:50:09.340,0:50:12.140 you can recycle the same problems over and[br]over 0:50:12.140,0:50:14.650 again. Once you find a couple that are easy 0:50:14.650,0:50:17.690 to explain and get everyone to wrap their[br]heads 0:50:17.690,0:50:20.150 around, you use them over and over and over 0:50:20.150,0:50:22.110 again, and you try them in different languages.[br]You 0:50:22.110,0:50:24.390 try them with different constraints. You just[br]try to 0:50:24.390,0:50:26.900 see if you can solve the dang problem. All 0:50:26.900,0:50:30.130 kinds of things come into your head in the 0:50:30.130,0:50:31.960 weeks in between when you do the Dojo, and 0:50:31.960,0:50:33.980 when you do the Dojo again. 0:50:33.980,0:50:36.430 Some of the common ones are like, Roman numberals- 0:50:36.430,0:50:41.060 Roman numeral conversions. Uncle Bob Martin's[br]famous one was 0:50:41.060,0:50:43.350 the bowling game. We did that one time at 0:50:43.350,0:50:46.210 the Coding Dojo in Orlando. We tried to do 0:50:46.210,0:50:47.860 the bowling game. One time. And what we discovered 0:50:47.860,0:50:49.380 is that nerds actually do not know how to 0:50:49.380,0:50:50.610 score bowling at all. 0:50:50.610,0:50:54.770 It is, that knowledge is completely encapsulated[br]in computer 0:50:54.770,0:50:56.770 software now and no one has committed any[br]of 0:50:56.770,0:50:59.020 it to memory. And does not even understand[br]how 0:50:59.020,0:51:02.210 that software runs anymore. We just know that,[br]occasionally, 0:51:02.210,0:51:06.820 turkeys come on the screen. And we have, only 0:51:06.820,0:51:10.700 if we have the numbers up, right. So. 0:51:10.700,0:51:12.060 Those are great resources for that. 0:51:12.060,0:51:13.080 C.S.: Take a break now? 0:51:13.080,0:51:15.330 D.R.: Yeah. Yeah. Let's take a break, and[br]when 0:51:15.330,0:51:18.490 we come back, we're gonna, we're gonna give[br]everybody 0:51:18.490,0:51:20.520 a post-it note, a different-color post-it[br]note. This is 0:51:20.520,0:51:24.660 some logistics. You'll pair up, or, pair up.[br]You'll 0:51:24.660,0:51:26.410 group up into groups of three and we'll do 0:51:26.410,0:51:29.500 like a Code, Code Retreat-style Coding Dojo[br]with the 0:51:29.500,0:51:31.880 entire group. We got a problem for you. We've 0:51:31.880,0:51:35.310 got some constraints for you. You can totally[br]use 0:51:35.310,0:51:37.780 what you've, what you've learned just right[br]now to 0:51:37.780,0:51:40.570 practice. We'll do that and we'll take another[br]break 0:51:40.570,0:51:42.500 and we'll do another Coding Dojo after that[br]with 0:51:42.500,0:51:43.030 a different problem. 0:51:43.030,0:51:43.240 C.S.: Cool. 0:51:43.240,0:51:44.300 D.R.: Don't have to participate in all three.[br]Don't 0:51:44.300,0:51:45.810 have to participate in any of them. 0:51:45.810,0:51:46.240 C.S.: Yup. 0:51:46.240,0:51:47.940 D.R.: If you don't really want to. But we 0:51:47.940,0:51:50.570 encourage you to, to come and, and play and 0:51:50.570,0:51:51.400 practice with us. 0:51:51.400,0:51:52.470 C.S.: All right. Fifteen minutes? 0:51:52.470,0:51:52.910 D.R.: Yup. 0:51:52.910,0:51:53.550 C.S.: Sounds good? 0:51:53.550,0:51:55.060 D.R.: We'll meet back in fifteen minutes. 0:51:55.060,0:51:55.930 C.S.: All right. Cool. 0:51:55.930,0:51:57.050 Before we start, I want to make sure that 0:51:57.050,0:52:00.650 everyone has Ruby installed. That is pretty[br]much the 0:52:00.650,0:52:04.400 only per-requisite, just to have Ruby, at[br]least 1.9.3, 0:52:04.400,0:52:07.000 I want to say, which is the version that 0:52:07.000,0:52:07.490 comes with miniTest, right. No one- 0:52:07.490,0:52:09.660 how to run, write Ruby from the command line? 0:52:09.660,0:52:16.660 How far down the rabbit hole do we need 0:52:17.170,0:52:18.840 to go? 0:52:18.840,0:52:21.300 C.S.: So if you want to see what version 0:52:21.300,0:52:27.820 of Ruby you have, you run ruby dash dash 0:52:27.820,0:52:28.850 version. And- 0:52:28.850,0:52:35.630 D.R.: In a, in a window that you can- 0:52:35.630,0:52:36.350 C.S.: There you go. Ruby dash dash version.[br]And 0:52:36.350,0:52:38.780 it should be, at least, 1.9.3. For this one, 0:52:38.780,0:52:40.880 I'm using 2 point 0, which is fine. You 0:52:40.880,0:52:42.210 don't have to be on 2 point 0, but 0:52:42.210,0:52:42.280 at least 1.9.3. 0:52:42.280,0:52:42.510 D.R.: And we'll show you that magic bash incantation 0:52:42.510,0:52:46.660 as well if you want to use that in 0:52:46.660,0:52:50.390 your, in your tests. 0:52:50.390,0:52:54.050 C.S.: Cool. So everyone has Ruby at least[br]1.9.3 0:52:54.050,0:52:57.250 and at least one text editor? Cool. 0:52:57.250,0:52:59.760 D.R.: Something emacs-flavored. 0:52:59.760,0:53:01.430 C.S.: Not. 0:53:01.430,0:53:06.380 Right. So the first problem, we want to group 0:53:06.380,0:53:10.760 into pairs of three, right. So, you might[br]have 0:53:10.760,0:53:15.210 gotten a post-it from David or maybe got yourselves, 0:53:15.210,0:53:17.350 and what we want to do is, we want 0:53:17.350,0:53:19.010 to group together into groups of three, with[br]people 0:53:19.010,0:53:21.840 with the same color post-its. So if you have 0:53:21.840,0:53:25.160 an orange post-it, you look for two other[br]people 0:53:25.160,0:53:26.260 with that same color post-it. 0:53:26.260,0:53:27.760 D.R.: And that, if you have- 0:53:27.760,0:53:31.010 C.S.: Someone's gonna have to get up. 0:53:31.010,0:53:36.520 Going over the etiquettes real quick. Test-driven[br]development, as 0:53:36.520,0:53:39.030 you might have seen us, David and I, doing 0:53:39.030,0:53:43.060 here, is red-green-refactor, so. You write[br]a failing test 0:53:43.060,0:53:47.520 before you write any production code. Giggles.[br]You make 0:53:47.520,0:53:50.220 that test pass. And if you need to, you 0:53:50.220,0:53:52.850 go back and you refactor, right. And then[br]you 0:53:52.850,0:53:54.610 do that cycle. That's the cycle that you want 0:53:54.610,0:53:55.230 to follow. So. 0:53:55.230,0:53:57.070 D.R.: And just because you get to a green 0:53:57.070,0:53:59.110 cycle does not mean you have to refactor. 0:53:59.110,0:53:59.650 C.S.: Right. 0:53:59.650,0:54:01.170 D.R.: But it's a good time to take a 0:54:01.170,0:54:03.990 break. Look, you know, look back at the code 0:54:03.990,0:54:05.760 as a pair, as a group, and say, should 0:54:05.760,0:54:06.050 we refactor? 0:54:06.050,0:54:06.390 C.S.: Yup. 0:54:06.390,0:54:08.650 D.R.: Is there something we can make simpler?[br]Is 0:54:08.650,0:54:10.570 there something we were copying and pasting?[br]Is there 0:54:10.570,0:54:12.370 a different way we could do this? Is there 0:54:12.370,0:54:14.790 another test we should add? Figure, take,[br]take your 0:54:14.790,0:54:16.470 break. Figure out what you're gonna do next. 0:54:16.470,0:54:18.110 C.S.: Right. And we're gonna do the ping pong 0:54:18.110,0:54:20.810 pairing, right. So just like David and I did, 0:54:20.810,0:54:22.810 you write a failing test. You pass it along 0:54:22.810,0:54:24.850 to your co-pilot. So you have three people.[br]Most 0:54:24.850,0:54:26.490 of you have three people. So you're gonna[br]have, 0:54:26.490,0:54:28.940 start with a pilot and a co-pilot, and then 0:54:28.940,0:54:31.360 the third person is gonna be the audience,[br]right. 0:54:31.360,0:54:33.900 And what we recommend is that the audience[br]does 0:54:33.900,0:54:37.010 not talk on red. What that means is that, 0:54:37.010,0:54:39.990 whenever there's a failing test, you let the[br]pair 0:54:39.990,0:54:42.730 figure out what the solution is, right. So[br]only 0:54:42.730,0:54:46.010 the driver and the co-pilot are part of trying 0:54:46.010,0:54:48.070 to figure out how to make that one test 0:54:48.070,0:54:48.360 pass. 0:54:48.360,0:54:50.340 D.R.: But don't think that you're stuck on[br]Alcatraz 0:54:50.340,0:54:54.260 or something. If you're a pair and, you may 0:54:54.260,0:54:56.510 be really new to Ruby, or maybe just new 0:54:56.510,0:54:58.500 to test-driven development and you're like,[br]I don't know 0:54:58.500,0:55:00.130 what to type here. Do you know what to 0:55:00.130,0:55:03.040 type here? I don't know what to type here. 0:55:03.040,0:55:06.800 Please ask your audience first, and if none[br]of 0:55:06.800,0:55:08.780 the three of you know what you're doing next 0:55:08.780,0:55:10.619 or what you need to do next, raise your 0:55:10.619,0:55:12.600 hand. We've got some helpers that'll be walking[br]around. 0:55:12.600,0:55:13.010 C.S.: Right. 0:55:13.010,0:55:13.619 D.R.: Helping out. 0:55:13.619,0:55:14.230 C.S.: And- yeah. 0:55:14.230,0:55:15.450 D.R.: We'll be walking around too. 0:55:15.450,0:55:18.380 C.S.: And, and the internet is not super cool, 0:55:18.380,0:55:21.690 but it's also good to look up. And, I 0:55:21.690,0:55:23.720 mean, internet's not reliable here, right.[br]But you're more 0:55:23.720,0:55:27.410 than free to look up documentation and references[br]and, 0:55:27.410,0:55:29.990 you know, ways to use the API and different 0:55:29.990,0:55:32.330 assertions that you can use. This is an open 0:55:32.330,0:55:33.100 book test. 0:55:33.100,0:55:35.340 D.R.: Yeah. And another thing to keep in mind 0:55:35.340,0:55:38.780 is IRB is open game as well. If you 0:55:38.780,0:55:40.830 are like, like, like you saw with us, when 0:55:40.830,0:55:42.250 we were doing the banana test- 0:55:42.250,0:55:42.750 C.S.: Right. 0:55:42.750,0:55:45.020 D.R.: We wrote a test to describe, to describe, 0:55:45.020,0:55:47.119 to assert what we thought the value of banana 0:55:47.119,0:55:49.100 would be when we passed it to integer. You're 0:55:49.100,0:55:51.460 more than welcome to just close down your[br]editor 0:55:51.460,0:55:55.390 or bring up IRB in whatever fashion you want 0:55:55.390,0:55:58.300 to. And, what is banana.to_i? Oh, it's zero.[br]That's 0:55:58.300,0:56:00.840 weird, but, you know. Whatever. 0:56:00.840,0:56:04.690 So, like, Kaikay was saying, don't talk, the[br]audience 0:56:04.690,0:56:06.500 shouldn't, whoever the audience member is,[br]if you have 0:56:06.500,0:56:09.630 one or two people, don't talk on red. If 0:56:09.630,0:56:12.200 you're not coding, keep quiet unless you're[br]part of 0:56:12.200,0:56:15.240 the pair, right. And it's time to switch. 0:56:15.240,0:56:16.760 If you have an idea, if you have something 0:56:16.760,0:56:18.660 - I think it should do this or I 0:56:18.660,0:56:20.720 think it should do that - rather than trying 0:56:20.720,0:56:22.360 to describe too much of it in English, I 0:56:22.360,0:56:24.360 mean, it might be helpful to, to talk about 0:56:24.360,0:56:26.410 it a little bit in English, show your work 0:56:26.410,0:56:28.350 in code. Show your idea in code. Just write 0:56:28.350,0:56:30.690 an assert statement that does what you think[br]it 0:56:30.690,0:56:32.190 needs to do. Ask the code a question. 0:56:32.190,0:56:34.030 C.S.: And this is not a code golf, right. 0:56:34.030,0:56:37.250 We're not here to show off, right, some Perl 0:56:37.250,0:56:39.820 black magic that you inherited from a previous[br]job. 0:56:39.820,0:56:42.550 So make sure that we're, whatever you write,[br]it's 0:56:42.550,0:56:45.160 explicit enough so that everyone in your group[br]understands, 0:56:45.160,0:56:47.060 right. So if you need to write a little 0:56:47.060,0:56:48.600 bit more. If you need to break out do 0:56:48.600,0:56:50.790 end from a curly brace, do a do end. 0:56:50.790,0:56:51.630 So do that. 0:56:51.630,0:56:54.320 D.R.: Right. And, as the audience, this is[br]like, 0:56:54.320,0:56:56.920 the one exception to the rule. If you see 0:56:56.920,0:57:00.930 the pair deviating from red-green-refactor,[br]like they start writing 0:57:00.930,0:57:04.230 production code before they write a test,[br]you get 0:57:04.230,0:57:06.990 to say, you know, eh, or test, or if 0:57:06.990,0:57:09.270 you see them sit on, they, they've written[br]some 0:57:09.270,0:57:11.460 code and they haven't run the test for awhile, 0:57:11.460,0:57:15.500 eh. Give them the buzzer. Survey says. And[br]if 0:57:15.500,0:57:17.400 you see somebody starting to use voodoo where,[br]whether 0:57:17.410,0:57:20.230 or not you're part of the pair, or they 0:57:20.230,0:57:22.960 just write something and you're like, what[br]is that? 0:57:22.960,0:57:26.300 Raise your hand and say no voodoo, or call 0:57:26.300,0:57:29.000 voodoo on them. Call molligan. Tell them to[br]do 0:57:29.000,0:57:29.580 it over. 0:57:29.580,0:57:30.869 C.S.: And that should be enough. 0:57:30.869,0:57:33.190 So you guys are in groups. You've selected[br]one 0:57:33.190,0:57:36.700 machine to work off of. And, please delete[br]all 0:57:36.700,0:57:38.619 the code that you had previously. Just make[br]sure 0:57:38.619,0:57:40.640 that you start from a blank slate. You're[br]looking 0:57:40.640,0:57:45.720 at a blank canvas. Blank text editor. Everyone[br]good 0:57:45.720,0:57:46.530 to start? 0:57:46.530,0:57:49.050 All right. So here's the problem that you're[br]gonna 0:57:49.050,0:57:50.090 do. 0:57:50.090,0:57:55.090 Boom. A calculator. It's gonna have one operation,[br]which 0:57:55.090,0:57:57.490 is gonna be addition. It should be able to 0:57:57.490,0:58:01.160 take a variable number of arguments, but,[br]we're gonna 0:58:01.160,0:58:03.280 add in a constraint. You're not allowed to[br]use 0:58:03.280,0:58:06.150 inject or, for that matter, reduce. 0:58:06.150,0:58:10.980 D.R.: This somewhat limits the playing field. 0:58:11.020,0:58:13.700 C.S.: Right. So that is the plan of action. And if- 0:58:13.860,0:58:15.680 D.R.: Any questions about the problem? Right? 0:58:17.640,0:58:18.140 C.S.: Cool? 0:58:18.140,0:58:19.880 D.R.: Everybody, everybody grasps the gist[br]of it? If 0:58:19.880,0:58:21.760 you guys get done with this before we get 0:58:21.760,0:58:23.900 done with the overall Dojo, feel free to do 0:58:23.900,0:58:26.600 what Kaikay and I did by expanding the problem. 0:58:26.600,0:58:28.840 What if we gave it strings? Or what if 0:58:28.840,0:58:31.880 we gave it, you know, bananas. Or what if 0:58:31.880,0:58:33.480 we threw an object at it? 0:58:33.480,0:58:34.200 C.S.: Right. 0:58:34.200,0:58:35.200 D.R.: Or whatever, you know. 0:58:35.200,0:58:36.480 AUDIENCE: Can you clarify inject? 0:58:36.480,0:58:40.940 D.R.: So, we were gonna use numbers dot inject. 0:58:40.940,0:58:42.240 We were gonna use array dot inject. 0:58:42.240,0:58:45.040 But as we pointed out the audience, we can also use 0:58:45.040,0:58:46.980 array dot reduce, which I'm much more familiar[br]with 0:58:46.980,0:58:50.100 since I come from JavaScript. So, don't use[br]inject. 0:58:50.100,0:58:53.360 Don't use the reduce methods. There is a third 0:58:53.360,0:58:58.560 option available to you. If you wanted to[br]look 0:58:58.560,0:58:59.510 at each- 0:58:59.510,0:59:00.720 C.S.: Right. 0:59:00.720,0:59:02.540 D.R.: Element in- 0:59:02.540,0:59:04.970 C.S.: -in an array. 0:59:04.970,0:59:07.390 D.R.: Just. Just saying. 0:59:07.390,0:59:11.950 C.S.: Cool. And we're gonna use three minute[br]rotation 0:59:11.950,0:59:14.990 time outs. So let's bring it up here. 0:59:14.990,0:59:19.990 AUDIENCE: [chatter] 0:59:20.700,0:59:21.560 C.S.: Oh no. 0:59:21.560,0:59:22.380 D.R.: Oh, you've got it. You can just stick 0:59:22.380,0:59:23.000 it over there. 0:59:23.000,0:59:27.600 C.S.: All right. So, let's do. Simple timer. 0:59:27.600,0:59:32.060 AUDIENCE: [chatter] 0:59:33.760,0:59:36.020 D.R.: Pop that on the side window there. The 0:59:36.020,0:59:36.560 other window. 0:59:37.320,0:59:42.580 C.S.: Yup. All right. So. So if you need, 0:59:43.130,0:59:45.770 or. Do we show, like, half of it and 0:59:45.770,0:59:46.840 half of that? 0:59:46.840,0:59:48.640 D.R.: Yeah. Yeah. Do the, do the presentation[br]again. 0:59:48.640,0:59:49.140 C.S.: This. 0:59:49.140,0:59:50.540 D.R.: Yeah. Let's do that. 0:59:53.119,0:59:54.959 C.S.: Well, but how do we show both at 0:59:54.960,0:59:55.520 the same time? 0:59:57.430,0:59:58.290 D.R.: Something bizarre. 0:59:58.290,0:59:59.110 C.S.: It's called moom. 0:59:59.110,0:59:59.710 AUDIENCE: Moom. 0:59:59.720,1:00:00.540 C.S.: Yeah. 1:00:00.540,1:00:01.280 AUDIENCE: Thank you. 1:00:01.680,1:00:04.060 D.R.: I use optimal layout, because it's basically[br]the 1:00:04.060,1:00:05.180 same thing. 1:00:05.500,1:00:08.240 C.S.: So if you need a start, your initial 1:00:08.250,1:00:11.060 code, kind of a cheat sheet. This is what 1:00:11.060,1:00:13.890 we used to start. So requiring minitest up[br]at 1:00:13.890,1:00:18.010 the top. Starting off with your test gaze.[br]And 1:00:18.010,1:00:19.710 then writing the first test. If you want to 1:00:19.710,1:00:22.030 set up like the auto run thing, is down 1:00:22.030,1:00:24.790 here at the bottom. 1:00:24.790,1:00:29.250 Remember. Ping pong. Write a failing test.[br]Pass it 1:00:29.250,1:00:30.840 along to your co-pilot. 1:00:30.840,1:00:36.790 D.R.: So then to do the timer, put the 1:00:36.790,1:00:40.760 timer up on the right screen. 1:00:40.760,1:00:44.730 C.S.: Full size? Close that down. 1:00:44.730,1:00:50.680 D.R.: You actually have to reduce the size[br]of 1:00:50.680,1:00:52.000 the font. 1:00:52.000,1:00:53.320 C.S.: Yeah. 1:00:53.320,1:00:54.650 D.R.: Awesome. 1:00:54.650,1:00:56.770 C.S.: All right. 1:00:56.770,1:01:00.150 D.R.: So we're gonna give you three minutes[br]to 1:01:00.150,1:01:02.610 go as a pair. Oh. We'll give you three 1:01:02.610,1:01:05.650 minutes as a pair, right. As the current pair. 1:01:05.650,1:01:07.520 And then when the timer goes off, switch.[br]And 1:01:07.520,1:01:09.530 we'll do the same thing, and after that, we'll 1:01:09.530,1:01:12.940 take, we'll do a little half time. 1:01:12.940,1:01:16.410 AUDIENCE: [chatter] 1:01:16.410,1:01:23.410 C.S.: All right. Let's stop for here. So,[br]stop 1:01:23.980,1:01:27.360 exactly where you are. All right. And now,[br]it's 1:01:27.360,1:01:29.890 time for us to do a little retrospective on 1:01:29.890,1:01:33.640 what we just did. On this round, right. So, 1:01:33.640,1:01:36.490 do we have enough pens here? 1:01:36.490,1:01:38.619 D.R.: We might. 1:01:38.619,1:01:40.960 C.S.: We at least have enough- 1:01:40.960,1:01:43.119 D.R.: Near enough. Enough pens per group. 1:01:43.119,1:01:46.580 So, just like an Agile retrospective, we're[br]gonna ask 1:01:46.580,1:01:49.980 each other just three question. What did we[br]do 1:01:49.980,1:01:51.910 well, that we would like to do the next 1:01:51.910,1:01:54.400 time we do this exercise? What would we like 1:01:54.400,1:01:57.420 to improve for the next time? So what did 1:01:57.420,1:01:59.110 we do well that we want to repeat? What 1:01:59.110,1:02:00.619 did we do maybe not so well, maybe we'd 1:02:00.619,1:02:02.970 like, maybe we'd like to improve for next[br]time. 1:02:02.970,1:02:04.470 And did we meet our goals and why? And, 1:02:04.470,1:02:06.770 again, our stated goals are not, did we solve 1:02:06.770,1:02:07.730 the problem? 1:02:07.730,1:02:10.030 That really wasn't ever an issue. That wasn't[br]really 1:02:10.030,1:02:13.600 any, I mean we, we can continue inventing[br]different 1:02:13.600,1:02:16.050 edge-cases to test this problem against. We[br]can continue 1:02:16.050,1:02:19.540 asking questions of this problem. Even this[br]simple problem, 1:02:19.540,1:02:21.600 for a very long time. So it's never really 1:02:21.600,1:02:23.700 about, did we solve the problem? No, the world 1:02:23.700,1:02:27.210 does not need another adder. 1:02:27.210,1:02:29.670 And most of the problems that we pick are 1:02:29.670,1:02:33.430 gonna be like that. But did we learn something? 1:02:33.430,1:02:36.119 Did we find out something new about Ruby or 1:02:36.119,1:02:38.420 about the people that we work with? Did we 1:02:38.420,1:02:40.820 practice our skills? Do we feel like we have 1:02:40.820,1:02:43.750 gained some skill or knowledge because of[br]this exercise? 1:02:43.750,1:02:46.250 And did we have fun? 1:02:46.250,1:02:48.940 So. We can just, we can start with the. 1:02:48.940,1:02:51.680 Just give you guys another three minutes to[br]figure 1:02:51.680,1:02:51.920 out- 1:02:51.920,1:02:52.410 C.S.: Yeah. 1:02:52.410,1:02:55.100 D.R.: Just ask yours- each other those three[br]questions. 1:02:55.100,1:02:56.450 Did we, what did we do well that we 1:02:56.450,1:02:58.480 want to do for the next one? What did 1:02:58.480,1:03:00.330 we do maybe not so well that we would 1:03:00.330,1:03:03.000 like to improve for the next one? And did 1:03:03.000,1:03:05.220 we meet our goals, and why or why not? 1:03:05.220,1:03:07.670 We'll give you guys another timer for that. 1:03:07.670,1:03:14.670 C.S.: Just write it down on the post-it note 1:03:15.920,1:03:17.320 we gave you, and then we can. 1:03:17.320,1:03:17.720 AUDIENCE: [chatter] 1:03:17.720,1:03:21.160 C.S.: All right. Cool. Stop exactly where[br]you are. 1:03:21.160,1:03:25.450 Go back to your editor. Delete everything.[br]And get 1:03:25.450,1:03:29.900 ready for the next problem. Again, same group.[br]Same 1:03:29.900,1:03:32.330 three minute rotation. But now we're gonna[br]do a 1:03:32.330,1:03:34.109 different problem, right. 1:03:34.109,1:03:37.450 Still on the calculator realm. Still gonna[br]be in 1:03:37.450,1:03:41.210 addition. But now your calc- your new calculator,[br]that 1:03:41.210,1:03:43.030 you're gonna start from scratch, is gonna[br]need to 1:03:43.030,1:03:48.240 take strings as arguments. As an example,[br]you're gonna 1:03:48.240,1:03:52.220 add one as a string, slash two, and it's 1:03:52.220,1:03:56.510 gonna need to return the integer three. 1:03:56.510,1:03:59.190 AUDIENCE: The integer or the string? 1:03:59.190,1:03:59.220 D.R.: The integer. 1:03:59.220,1:04:00.040 C.S.: The integer. To make it- 1:04:00.040,1:04:04.140 D.R.: Stop wherever you want to stop. 1:04:04.140,1:04:09.410 I, I believe there was an earlier presentation[br]on 1:04:09.410,1:04:10.580 just enough. 1:04:10.580,1:04:11.750 AUDIENCE: [chatter] 1:04:11.750,1:04:12.930 C.S.: Cool. 1:04:12.930,1:04:17.470 D.R.: And you can choose to you, you can 1:04:17.470,1:04:20.670 choose that last constraint that we offered.[br]The don't 1:04:20.670,1:04:24.390 use inject. You can, and, take it or leave 1:04:24.390,1:04:27.770 it, right. Doing the calc add with strings[br]might 1:04:27.770,1:04:28.350 be- 1:04:28.350,1:04:30.510 C.S.: More than a big problem to solve. 1:04:30.510,1:04:32.760 D.R.: Right. So, if you want to use inject 1:04:32.760,1:04:33.570 or reduce or yo mama, whatever. It doesn't[br]matter. 1:04:33.570,1:04:34.450 The only, the only requirement we will have[br]is, 1:04:34.450,1:04:35.330 you have to take, you have to accept strings, 1:04:35.330,1:04:36.200 like, one, two, three, four, in, in words,[br]t-h, 1:04:36.200,1:04:38.840 you know, r-e-e. You go up to ten. You 1:04:38.840,1:04:42.300 go up to one-hundred. I don't care. How far 1:04:42.300,1:04:49.109 you want to go. Cause you, there may be 1:04:49.109,1:04:52.070 some typing involved. 1:04:52.070,1:04:54.050 C.S.: Right. 1:04:54.050,1:05:00.100 AUDIENCE: You still want it to return an integer 1:05:00.100,1:05:01.660 or a string? 1:05:01.660,1:05:03.030 D.R.: It should return an integer. 1:05:03.030,1:05:03.740 AUDIENCE: [indecipherable] - or should you[br]forget integers? 1:05:03.740,1:05:06.100 C.S.: Forget. Array delete what you had, and[br]then 1:05:06.100,1:05:10.170 start from scratch, right. 1:05:10.170,1:05:17.170 D.R.: And really, start from scratch. Even[br]back to 1:05:24.530,1:05:25.170 the boiler plate that we gave you guys. 1:05:25.170,1:05:25.359 AUDIENCE: [chatter] 1:05:25.359,1:05:25.920 C.S.: All right everybody. Pencils down. 1:05:25.920,1:05:26.290 D.R.: No more coding. 1:05:26.290,1:05:29.440 C.S.: And just like we did before. Quick retrospective. 1:05:29.440,1:05:32.119 Write down things that worked well for this[br]round. 1:05:32.119,1:05:39.119 Things that could have been better and need[br]improvement 1:05:39.650,1:05:40.000 for upcoming rounds. 1:05:40.000,1:05:41.810 D.R.: And also as a process, as a whole. 1:05:41.810,1:05:45.090 Like, what did you guys like about the whole 1:05:45.090,1:05:47.990 process? What did you guys, what would you[br]guys 1:05:47.990,1:05:50.000 improve about this workshop if you were to[br]go 1:05:50.000,1:05:52.670 to it again? And did you- did we meet 1:05:52.670,1:05:55.540 our goals, and why or why not? So we'll 1:05:55.540,1:05:56.920 give you a couple minutes to do that real 1:05:56.920,1:05:59.810 quick as a group. No more coding. I will 1:05:59.810,1:06:01.930 come by and delete your files. 1:06:01.930,1:06:06.200 So, did we learn something? Everybody learn[br]something? Feel 1:06:06.200,1:06:10.340 like you pulled something your way? Did we[br]practice? 1:06:10.340,1:06:14.450 Do you feel like you've practiced some? Did[br]we 1:06:14.450,1:06:19.300 solve the problem? Some? Solved some of the[br]problem, 1:06:19.300,1:06:22.520 right. Ish. Solved-ish the problem. 1:06:22.520,1:06:23.609 Did we have fun? 1:06:23.609,1:06:24.690 AUDIENCE: Yeah. Yes. Yeah. 1:06:24.690,1:06:25.230 D.R.: Awesome. 1:06:25.230,1:06:25.770 C.S.: Cool. 1:06:25.770,1:06:27.720 D.R.: So, if you want to know more about 1:06:27.720,1:06:31.670 the Coding Dojo, this is Kaikay's new favorite[br]book. 1:06:31.670,1:06:35.630 Coding Dojo Handbook. I'm totally picking[br]up a copy. 1:06:35.630,1:06:37.630 There's way more resources out there. There[br]are local 1:06:37.630,1:06:39.310 meet up groups. You should take this to your 1:06:39.310,1:06:42.330 user group. We started a whole group around[br]Coding 1:06:42.330,1:06:45.780 Dojo in, in Orlando. But we also, because[br]I 1:06:45.780,1:06:47.730 ran the PHP group and I ran the Python 1:06:47.730,1:06:49.050 group at the time, we also used it for 1:06:49.050,1:06:51.550 the Python group and the PHP group. We'll[br]probably 1:06:51.550,1:06:54.160 do it again at node. We've done it at 1:06:54.160,1:06:57.580 Ruby. We've done it all the user groups around. 1:06:57.580,1:06:58.580 If you want to know, if you want to 1:06:58.580,1:07:00.540 get some starting points for that, I wrote[br]a 1:07:00.540,1:07:03.720 blog post on getting start, getting past all[br]the 1:07:03.720,1:07:06.869 Yak shaving of setting up the automated tests[br]running 1:07:06.869,1:07:09.130 in the background and the boilerplate for[br]each one 1:07:09.130,1:07:11.150 of the, for each one of the different languages 1:07:11.150,1:07:12.100 you want to try. 1:07:12.100,1:07:14.630 That's in the Orlando Dojo reporepo on, on[br]GitHub. 1:07:14.630,1:07:17.369 It's, or the Orlando Dojo organization. 1:07:17.369,1:07:22.090 C.S.: Talking about meet ups. The best way[br]to 1:07:22.090,1:07:25.270 actually experience more of this is to do[br]it 1:07:25.270,1:07:29.340 in practice, right. So. So go ahead to meet 1:07:29.340,1:07:31.970 up dot com and look for nearby Coding Dojo 1:07:31.970,1:07:36.400 meet ups. There's plenty of them out there,[br]and 1:07:36.400,1:07:39.119 if you don't find one, more than welcome to 1:07:39.119,1:07:41.990 create one yourself. All you need is a friend 1:07:41.990,1:07:45.320 who you can pair with every week or so, 1:07:45.320,1:07:47.109 and then, if you just put it out there, 1:07:47.109,1:07:50.350 put it online that you guys are meeting every 1:07:50.350,1:07:52.920 week at this specific place at this specific[br]time, 1:07:52.920,1:07:54.359 people will show up. Believe me. 1:07:54.359,1:07:56.130 D.R.: Right. Just be consistent. 1:07:56.130,1:07:59.500 C.S.: Yeah. Just be consistent. And, I think[br]that's 1:07:59.500,1:08:01.480 it for today. If you guys want to talk 1:08:01.480,1:08:02.880 more about this and that-