Huston we have a problem: Bug patrol
Testing is the heart of developing. Bugs are ok don't fear them we make them all the time. In this video we figure out what the bug is and then isolate it so we can fix it. By the end of this video we figure out what the problem was and fix it.
Video Transcript
00:00Almost out of the clear and again when we look at our device, I know it's kind of hard to see it through the monitor
00:05But if you're following along as we're coding, you'll notice that horizontally it's working perfectly
00:10But as soon as I align it even though everything seems okay
00:13Notice how the inches are actually not drawing out the full inches
00:17It seems as if that it's still maintaining the same
00:21Lines that it created when it was in the horizontal place, but we know we're refreshing it so that can't be the case
00:27So to be able to solve this we're gonna terminate first the debugging mode and go back into our place
00:32Let me just connect my phone
00:35Alright, so I'm gonna connect my phone and once I connect my phone
00:37I want to do a little test to try to figure out why this is happening now when debugging one of the stuff is you always
00:43Want to do and by the way?
00:44It's a bug it deliberately we made it because one of the most critical steps in learning how to program is
00:48Learning how to deal with bugs now if we created a perfect application that you wouldn't really learn anything from it
00:54So the first step is we need to isolate where the problem is
00:57First of all, we know that we have a problem with our total inches because we're not getting the right amount of total inches
01:02So the first step that I'm gonna do is I want to create a little trace
01:05I'm gonna go into my refresh loader and right after we set our horizontal
01:10Variable I just want to trace that out. So I'm gonna trace out
01:15horizontal
01:16inches are
01:18And I'm just gonna put inside here our total are not total but total
01:24Inches and that's really all I want. I'm just gonna run it on my device again
01:28so I'm gonna click on the command shift and return and
01:31Let me make sure that I don't have any errors first. Let me just grab the compiler error
01:35It's acting undefined property total inches means that I have some sort of typo there
01:39So let's go right back into that total inches that we just created and I'm just going to make sure that I copy paste
01:44Instead of maintaining and continuing having errors. I'm gonna copy that paste that right in there making sure that I got the right name inside there
01:51Save that I'm gonna click on that command shift enter or command shift return and I'm gonna get it to run on my mobile device
01:57I'm not gonna deep plug it but what I'm gonna do
01:59I'm gonna set it to be horizontal and vertical and see if the information that I'm getting is accurate because I'm hoping to get
02:05two inches and then four inches
02:07So I'm just gonna grab my phone. So initially it's two and I'm gonna rotate it once I rotate it notice what's happening
02:13We're still at the horizontal inches or two every time I'm rotating. It's telling me something
02:19It's telling me that the amount of inches that I'm getting is just not correct
02:22So I'm gonna stop that debugging session and go right back into that line where I'm creating my actual inches and try to figure out
02:29What's going on now? I know my inches is correct
02:32So the only thing that could be incorrect is the information that I'm getting from my capabilities library
02:37The reason is now that we've noticed it is because my screen resolution is a static property
02:43It doesn't change. So although it's setting it with an X that is a little bit confusing
02:47It's actually setting it as always there
02:50So we need to figure out a more dynamic way of getting what is the current actual width of our application?
02:56Lucky for us. That's really easy to do that
02:58I'm just gonna use a property stage stage width which we met earlier and we're gonna make sure we're gonna change our
03:05Height as well by calling the stage
03:07That stage height and that way we found our bug because we knew it had to be inside of the total inches and once we knew that
03:14And we isolated it we figure it out
03:16What is the variable that was wrong and now we're replacing the variable to see if the new variable is what is right?
03:22So I'm gonna save it one more time and just run my application one more time and this time around
03:26I'm expecting to get the variables two four two
03:30So I'm expecting to get two inches then four inches and then back to two and if that does happen
03:34We should get our refresh to work perfectly. So again, I'm gonna grab my device open it up and I'm gonna rotate it
03:41Once I rotate it notice how we're getting four now and when I rotate it back
03:45We're going back to two and if I disconnect my plug again
03:48Just so you bail a seat so you can see it all so live and I don't know if you could see it
03:51Well, you'll notice that when I rotate it our bars are now working perfectly and same when it's horizontal
03:58So now it's working at any given time. So there we go
04:00We completed adding our inches of steps are a little bit complicated in the next video
04:05We're gonna add those smaller steps inside inside of the inch to enable people to be able to count a half an inch or a quarter
04:11Of an inch more easily
