1 00:00:00,820 --> 00:00:03,030 Okay, so let's tackle this issue here. 2 00:00:03,030 --> 00:00:09,670 This is issue number 6, and I'm gonna go ahead and assign it to me, there we go. 3 00:00:10,920 --> 00:00:14,160 Now since this is a git repository in my team, that's you, 4 00:00:14,160 --> 00:00:15,710 you could be working on something else. 5 00:00:15,710 --> 00:00:18,440 I'm gonna do all my work in a brand new branch, and 6 00:00:18,440 --> 00:00:22,080 I'm gonna keep my changes separate from what's happening on the master. 7 00:00:22,080 --> 00:00:25,370 So I'm gonna do that by creating a new branch down here, I'm gonna choose 8 00:00:25,370 --> 00:00:29,910 New Branch, and it should be something similar to what the topic is, right? 9 00:00:29,910 --> 00:00:34,120 So the topic of that issue is fewer-examples, right, 10 00:00:34,120 --> 00:00:36,890 we want it to go from five to three. 11 00:00:36,890 --> 00:00:38,630 Okay, so that code that we saw, 12 00:00:38,630 --> 00:00:41,030 what we wanna do is we wanna just change this to three, right? 13 00:00:42,464 --> 00:00:45,437 Why don't we leave things a little bit cleaner than when we found them? 14 00:00:45,437 --> 00:00:48,689 I mean, so remember how we wanna share with that fiber represented when we 15 00:00:48,689 --> 00:00:49,710 first saw this? 16 00:00:49,710 --> 00:00:53,360 Let's make this a constant so the next person will for sure understand. 17 00:00:53,360 --> 00:00:59,040 So one thing to do is you can choose this choose it and choose Refactor, Extract, 18 00:00:59,040 --> 00:01:02,210 Constant, and then we’ll get rid of that magic number that was there, right? 19 00:01:02,210 --> 00:01:06,330 Let’s call this AMOUNT_TO_ SHOW. 20 00:01:06,330 --> 00:01:09,830 And that created up here, created a new public static final entity now to show. 21 00:01:09,830 --> 00:01:13,160 Cool, so now everybody can access that and it reads cleaner. 22 00:01:13,160 --> 00:01:14,690 No more magic numbers. 23 00:01:15,690 --> 00:01:19,650 I'm gonna go ahead and I want to leave this breakpoint here in case I want things 24 00:01:19,650 --> 00:01:23,930 to stop and I do wanna run this in debug mode just in case we forget, 25 00:01:23,930 --> 00:01:25,890 in case something didn't work like we wanted. 26 00:01:25,890 --> 00:01:30,440 So I'm gonna choose the Debug app, and while 27 00:01:31,720 --> 00:01:35,080 all this is going and debugging, I can come over here and I can do this thing. 28 00:01:35,080 --> 00:01:37,230 I don't want it to stop, I want it to run. 29 00:01:37,230 --> 00:01:39,330 So I can do a thing called muting breakpoints and 30 00:01:39,330 --> 00:01:40,070 that's this thing over here. 31 00:01:40,070 --> 00:01:41,540 I'm gonna mute the breakpoints. 32 00:01:41,540 --> 00:01:42,290 So I'm gonna click this. 33 00:01:43,370 --> 00:01:44,730 Notice how it got grayed out here. 34 00:01:44,730 --> 00:01:49,380 So now it won't stop, it's not enabled, is that word for that. 35 00:01:50,690 --> 00:01:53,010 Cool, so I'm gonna go and refresh the page. 36 00:01:54,220 --> 00:01:56,730 There we go, and there's three, awesome. 37 00:01:56,730 --> 00:01:58,980 And they're right, it does look better. 38 00:01:58,980 --> 00:02:02,550 I like that there's only three, but there's eight more. 39 00:02:02,550 --> 00:02:05,060 That total is off, we've got to fix that. 40 00:02:05,060 --> 00:02:06,010 So let's do this. 41 00:02:06,010 --> 00:02:07,400 Let's come back. 42 00:02:07,400 --> 00:02:13,950 Let's go ahead and unmute, and see how it turned red again, and I'm gonna refresh. 43 00:02:13,950 --> 00:02:16,440 And boom, here we are back, and I'm gonna go ahead and 44 00:02:16,440 --> 00:02:21,030 I'm gonna drop a line right here on this and, line. 45 00:02:21,030 --> 00:02:24,510 And one thing that we can do is we can continue to that breakpoint since one 46 00:02:24,510 --> 00:02:27,347 exists, this will resume the program and will hit the next breakpoint, boom. 47 00:02:29,080 --> 00:02:31,140 So what was this doing? 48 00:02:31,140 --> 00:02:34,500 Right, it's getting the total count and it's appending the total count. 49 00:02:34,500 --> 00:02:38,070 Now before I change this, why don't we fix we know that we got the three thing 50 00:02:38,070 --> 00:02:39,680 working and that's a good unit of work. 51 00:02:39,680 --> 00:02:43,940 Let's make a commit first, right, so I'm gonna go to version control here, and 52 00:02:43,940 --> 00:02:48,560 I'm gonna click this VCS button here which is for committing changes or 53 00:02:48,560 --> 00:02:50,420 some other things that have been changed. 54 00:02:50,420 --> 00:02:53,590 So I'm gonna unclick this miscellaneous because that's not related to what this 55 00:02:53,590 --> 00:02:54,340 commit is about. 56 00:02:54,340 --> 00:02:56,800 So let's see the commit message for this. 57 00:02:56,800 --> 00:03:03,046 Let's think, it's addresses issue number 58 00:03:03,046 --> 00:03:10,120 6 by changing the number of examples to 3, cool. 59 00:03:10,120 --> 00:03:13,720 So I'm gonna go ahead and commit that and 60 00:03:13,720 --> 00:03:16,930 we've been warned that there is some possible things wrong. 61 00:03:16,930 --> 00:03:19,920 I'm gonna go ahead and not do that cuz I'm pretty happy with where things are at. 62 00:03:19,920 --> 00:03:20,600 I wanna choose Commit. 63 00:03:22,240 --> 00:03:26,060 And I wanna say No, it's talking about the miscellaneous thing there. 64 00:03:26,060 --> 00:03:27,000 We'll take care of that later. 65 00:03:28,020 --> 00:03:30,620 Okay, so let's tackle our next problem. 66 00:03:30,620 --> 00:03:35,130 So we have the total but it really should be the total without the things that have 67 00:03:35,130 --> 00:03:38,200 been shown and thankfully now that we have that constant we can use that. 68 00:03:38,200 --> 00:03:43,440 So if we say the total amount to show there, 69 00:03:43,440 --> 00:03:49,280 let's get this back and they debug window here and I'm gonna go ahead and 70 00:03:49,280 --> 00:03:53,496 restart the debugger because we just changed that code so let's do that, and 71 00:03:53,496 --> 00:03:59,150 I don't want it to stop at this first one, but I do want it to stop there. 72 00:03:59,150 --> 00:04:01,580 So I can actually right-click this and 73 00:04:01,580 --> 00:04:06,220 choose that one specifically to be disabled, right? 74 00:04:06,220 --> 00:04:09,460 So see how it's got a little different thing versus the muting of it. 75 00:04:09,460 --> 00:04:13,080 So I'm gonna go ahead and let's refresh. 76 00:04:14,580 --> 00:04:19,300 Okay, so, you know what, actually what if we come in here and 77 00:04:19,300 --> 00:04:22,940 the amount to show is more than the total count. 78 00:04:22,940 --> 00:04:25,510 Now since we don't have tests in place, 79 00:04:25,510 --> 00:04:28,690 we can't really easily reproduce that situation to see what happened, but 80 00:04:28,690 --> 00:04:32,090 what we can do, is we can fudge the numbers, right? 81 00:04:32,090 --> 00:04:35,277 So we can fudge what total count is, let's go ahead and do that. 82 00:04:35,277 --> 00:04:39,310 So I'm gonna step over once more, and you'll see the total counts down here, and 83 00:04:39,310 --> 00:04:42,200 you can actually fudge these numbers, it's kinda cool. 84 00:04:42,200 --> 00:04:42,730 So check this out. 85 00:04:42,730 --> 00:04:47,090 So you right-click here, and just use Set Value, and total count is a long, 86 00:04:47,090 --> 00:04:49,690 so I'm gonna press 1 and then L to represent a long. 87 00:04:50,890 --> 00:04:53,630 Okay, so now total count is set as a long. 88 00:04:53,630 --> 00:04:58,490 And so when this goes through here, it's going to, we can see what happens, 89 00:04:58,490 --> 00:05:00,130 right, so let's do that. 90 00:05:00,130 --> 00:05:01,315 Let's take a look. 91 00:05:01,315 --> 00:05:03,150 Uh-oh. 92 00:05:03,150 --> 00:05:07,480 Refresh your memory about those and -2 more. 93 00:05:07,480 --> 00:05:09,070 Yikes, that's horrible. 94 00:05:09,070 --> 00:05:11,230 We have to make sure that doesn't happen, right? 95 00:05:11,230 --> 00:05:13,410 So that sounds like a good job for an if statement, right? 96 00:05:13,410 --> 00:05:19,680 So let's go ahead and I'm gonna move the total count line up. 97 00:05:19,680 --> 00:05:21,230 And that actually wiped out the debugger, 98 00:05:21,230 --> 00:05:25,490 I wanna press stop on the debugger and let's go ahead, 99 00:05:25,490 --> 00:05:30,760 I'll add a debugger line there and we're gonna add an if statement here. 100 00:05:30,760 --> 00:05:32,360 So what is that if statement, so if 101 00:05:33,950 --> 00:05:38,320 the total count is greater than the amount to show, right? 102 00:05:38,320 --> 00:05:43,390 As long as there are some left then we should show and, right, 103 00:05:43,390 --> 00:05:44,180 that seems to work. 104 00:05:44,180 --> 00:05:48,830 I’m going to move these lines up and we pressed tab, there they go. 105 00:05:50,890 --> 00:05:52,250 Now before we kick this off, 106 00:05:52,250 --> 00:05:55,690 I wanna show you a couple of breakpoint options that we have. 107 00:05:55,690 --> 00:05:59,650 So if you click down here, you can see View Breakpoints and 108 00:05:59,650 --> 00:06:02,750 will show you all of the breakpoints that you have currently open and 109 00:06:02,750 --> 00:06:05,250 you can see here this one is disabled and this one is not and 110 00:06:05,250 --> 00:06:09,550 you could imagine as you get better at this they're gonna be all over the place. 111 00:06:09,550 --> 00:06:12,620 And it gets unmanageable to flip between each file and enable and 112 00:06:12,620 --> 00:06:13,720 disable like we just did. 113 00:06:13,720 --> 00:06:16,100 So this grouping here is kind of a lifesaver, right? 114 00:06:16,100 --> 00:06:20,040 So this goes between packages and this one goes between files and 115 00:06:20,040 --> 00:06:22,988 this one will group just between classes them self. 116 00:06:24,200 --> 00:06:27,540 So it's nice with these groupings if you wanna disable all of these you just check 117 00:06:27,540 --> 00:06:29,460 that and you could do that per file, right? 118 00:06:29,460 --> 00:06:31,516 So if you had other files they'd be showing up here and 119 00:06:31,516 --> 00:06:33,449 you can turn off just this file, turn this one on. 120 00:06:33,449 --> 00:06:37,369 So the next stop in is that you can have a breakpoint 121 00:06:37,369 --> 00:06:40,330 that doesn't suspend execution, right? 122 00:06:40,330 --> 00:06:43,110 So let's do that first point that we have in here right where it 123 00:06:43,110 --> 00:06:46,030 stop them in the ctaBuilderlet, let's make it not suspend but 124 00:06:46,030 --> 00:06:48,780 let's actually make it log a message to the console. 125 00:06:48,780 --> 00:06:52,530 Okay, so what happens then is when that line comes through, it's going to 126 00:06:52,530 --> 00:06:55,560 write out what happened and what will take a look at it here in a second. 127 00:06:55,560 --> 00:06:58,380 The other thing that you can do here, so this is handy for 128 00:06:58,380 --> 00:07:02,522 when you're in sort of in a loop and you don't wanna actually pause on each thing, 129 00:07:02,522 --> 00:07:06,183 you might wanna come in here, let's go let's drop a breakpoint here and 130 00:07:06,183 --> 00:07:09,879 you can get to that screen also by right clicking and choosing More here. 131 00:07:11,346 --> 00:07:16,198 So let's see that specific break point that we just dropped is here and 132 00:07:16,198 --> 00:07:20,968 we also don't want this thing to Suspend but we're also gonna here, 133 00:07:20,968 --> 00:07:25,081 let's log, we can use a Java statement here and we can say, 134 00:07:25,081 --> 00:07:29,935 card definition is,.and you can just, you have access to what has it 135 00:07:29,935 --> 00:07:35,170 ever in your current state there and all the awesome autocomplete. 136 00:07:35,170 --> 00:07:38,900 So basically, that's the system print line message [LAUGH] that you littered all over 137 00:07:38,900 --> 00:07:43,250 the code normally but here you can just be stored there in that break point. 138 00:07:43,250 --> 00:07:43,950 Pretty nice, right? 139 00:07:45,840 --> 00:07:48,790 So remember these first two are set to not suspend and 140 00:07:48,790 --> 00:07:51,160 this third one is where we're going to stop. 141 00:07:51,160 --> 00:07:55,370 So I'm gonna go ahead, I'm gonna restart the debugger and 142 00:07:55,370 --> 00:07:59,180 if I come over here and refresh, we're gonna pause, right, 143 00:07:59,180 --> 00:08:03,390 it went right through these two and it stopped here on the total count. 144 00:08:03,390 --> 00:08:04,590 Awesome, right? 145 00:08:04,590 --> 00:08:07,330 And if we look over here in the console, we can see that the breakpoint was 146 00:08:07,330 --> 00:08:11,760 reached, and it has a link to where that breakpoint was happening, 147 00:08:11,760 --> 00:08:14,420 that's what it looks like when you don't suspend it, you just log it out, and 148 00:08:14,420 --> 00:08:16,960 then this is the evaluated expression. 149 00:08:16,960 --> 00:08:17,880 Pretty cool, right? 150 00:08:17,880 --> 00:08:21,918 So much handier and better than lettering your code with system help print lines. 151 00:08:22,980 --> 00:08:24,820 Well, since we're here, let's once more, 152 00:08:24,820 --> 00:08:27,880 let's change this value of what that total count is. 153 00:08:27,880 --> 00:08:32,150 So let's get back to our debugger, total count here were set to 8, 154 00:08:32,150 --> 00:08:36,780 we're gonna change this to be 1L and I will continue through. 155 00:08:38,220 --> 00:08:38,980 There we go, so 156 00:08:38,980 --> 00:08:43,300 it doesn't say and how ever many more because they're not there, awesome. 157 00:08:44,960 --> 00:08:49,589 Now we are ready to commit that change so let's go to our version control and 158 00:08:49,589 --> 00:08:50,921 we'll choose this. 159 00:08:50,921 --> 00:08:55,918 And we'll make this also not include this 160 00:08:55,918 --> 00:08:59,773 miscellaneous and we'll say, 161 00:08:59,773 --> 00:09:04,912 Addresses bug described in number 6 where 162 00:09:04,912 --> 00:09:10,352 the total count in the call to action was off. 163 00:09:12,012 --> 00:09:15,550 Cool and I'm gonna choose commit and I'm gonna choose commit and 164 00:09:15,550 --> 00:09:18,870 push this time because I'm gonna push this up to GitHub. 165 00:09:18,870 --> 00:09:21,060 This is a common practice, I'll show you here in a second. 166 00:09:21,060 --> 00:09:23,650 So we'll commit and push and we'll say Commit. 167 00:09:25,110 --> 00:09:30,750 And this is saying here that on it's gonna create a new branch called fewer examples. 168 00:09:30,750 --> 00:09:34,261 So that's what we want, we're gonna push that up to GitHub, let's push that. 169 00:09:37,177 --> 00:09:38,498 So now if we go to GitHub and 170 00:09:38,498 --> 00:09:42,342 we take a look we'll see that there's a new branch that has been pushed up and 171 00:09:42,342 --> 00:09:46,800 it's asking me if I want to compare and do a pull request and I do indeed. 172 00:09:46,800 --> 00:09:51,210 Now by default that's gonna go try to jump across the fork but I don't I don't want 173 00:09:51,210 --> 00:09:54,060 to go across the fork, I wanna do this in our branch here first. 174 00:09:54,060 --> 00:09:58,358 So let's do this, let's change the base fork to be mine, 175 00:09:58,358 --> 00:10:01,263 not the master treehouse one, right? 176 00:10:01,263 --> 00:10:03,100 Okay? 177 00:10:03,100 --> 00:10:06,570 And it's now, tell me that it's able to merge and I'm doing this cuz I wanna 178 00:10:06,570 --> 00:10:11,390 share it with you, so this is fewer examples on the homepage and says, 179 00:10:11,390 --> 00:10:14,040 this is directly related to number 6. 180 00:10:15,760 --> 00:10:20,180 I got it figured out, all right, something in here. 181 00:10:21,200 --> 00:10:26,073 Also fixed weird total bug, and 182 00:10:26,073 --> 00:10:31,060 so I'm going to do this and it will show you in here all the changes that 183 00:10:31,060 --> 00:10:33,430 were made in notice that it's linking here. 184 00:10:33,430 --> 00:10:38,307 So I wanna go ahead and create this pull request, And let's imagine that 185 00:10:38,307 --> 00:10:41,862 you come in here and you wanna look at the commits that I did and 186 00:10:41,862 --> 00:10:45,417 then you wanna come to the issue and take a look at the issue and 187 00:10:45,417 --> 00:10:50,140 you can also see that now If you walked into here, it comes in here. 188 00:10:50,140 --> 00:10:53,590 So you can see that the six is here. 189 00:10:53,590 --> 00:10:55,990 So let's go ahead and look at the pull request. 190 00:10:58,370 --> 00:10:59,170 You came in here. 191 00:10:59,170 --> 00:11:02,300 You look at it. You say that that looks great and 192 00:11:02,300 --> 00:11:04,400 you're gonna choose merge pull request. 193 00:11:05,960 --> 00:11:07,508 And you're going to confirm the merge. 194 00:11:10,868 --> 00:11:14,090 So now, master has the merge request, thanks. 195 00:11:15,320 --> 00:11:18,660 Let's take a quick look one more time at those break point options, okay so 196 00:11:18,660 --> 00:11:23,600 if I come back and I come into our break point options One thing that I wanted to 197 00:11:23,600 --> 00:11:29,760 show you here on the suspend is that there is all and there is thread. 198 00:11:29,760 --> 00:11:32,990 Our spring application is in fact multi-threaded, so 199 00:11:32,990 --> 00:11:36,620 the server can continue running and handle multiple requests. 200 00:11:36,620 --> 00:11:39,890 Now what we've done here is we've stopped all of the threads. 201 00:11:39,890 --> 00:11:41,960 You can actually navigate through the threads down here. 202 00:11:43,570 --> 00:11:45,530 See how they have these different threads and 203 00:11:45,530 --> 00:11:49,200 if you ever got lost in these different places you can always find the little one 204 00:11:49,200 --> 00:11:51,450 with the check mark to get back to the thread. 205 00:11:51,450 --> 00:11:54,560 So our web applications are probably never ever going to do that but there 206 00:11:54,560 --> 00:11:57,130 might be other applications that you're running where you want to pause a single 207 00:11:57,130 --> 00:12:01,630 thread just to keep the rest of the world moving Now that we have a vibe for 208 00:12:01,630 --> 00:12:04,690 what is happening, we really should contemplate writing tests. 209 00:12:04,690 --> 00:12:07,630 But doing that extra work, you know, taking the time to get unit test up and 210 00:12:07,630 --> 00:12:10,620 running, well, that might end up completely blowing out our time estimate 211 00:12:10,620 --> 00:12:12,650 that we agreed upon with the client. 212 00:12:12,650 --> 00:12:16,440 Now, don't get me wrong, it most certainly will save us time in the future, but for 213 00:12:16,440 --> 00:12:18,530 now, that's not really our call, right? 214 00:12:19,640 --> 00:12:20,730 Let's do this. 215 00:12:20,730 --> 00:12:24,360 Whole shoot the client an email explaining that we really should be writing test. 216 00:12:24,360 --> 00:12:26,590 And explain the benefits of testing and yada yada. 217 00:12:26,590 --> 00:12:30,230 And we'll see if that's something that they're interested in investing it. 218 00:12:30,230 --> 00:12:31,390 I'll do my best. 219 00:12:31,390 --> 00:12:33,895 All drop the email in the teacher Teachers notes here when I'm done just so 220 00:12:33,895 --> 00:12:36,285 you can see how to approach this delicate issue 221 00:12:36,285 --> 00:12:38,325 that is if you're interested it happens quite a bit. 222 00:12:39,415 --> 00:12:43,265 I'm glad we're taking the time to explore the debugger it's a really powerful tool 223 00:12:43,265 --> 00:12:46,685 and the more you know what it's capable of doing the more you'll use it. 224 00:12:46,685 --> 00:12:49,285 Let's take a quick break and then come back and explore frames and 225 00:12:49,285 --> 00:12:50,685 how to rewind history. 226 00:12:50,685 --> 00:12:53,705 Don't worry we'll deal with the oddities of time travel with the greatest of ease 227 00:12:53,705 --> 00:12:54,395 thanks to our debugger.