Practical Debugging

Video in TIB AV-Portal: Practical Debugging

Formal Metadata

Practical Debugging
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
People give ruby a bad reputation for speed, efficiency, weak typing, etc. But one of the biggest benefits of an interpreted language is the ability to debug and introspect quickly without compilation. Oftentimes developers reach for heavy-handed libraries to debug their application when they could just as easily get the information they need by using tools they already have. In this talk you will learn practical techniques to make debugging easier. You will see how simple techniques from the ruby standard library can greatly increase your ability to keep your codebase clean and bug-free.
Computer animation
Dependent and independent variables Computer animation Stack (abstract data type)
Protein folding Arm Computer animation Software developer Multiplication sign Forcing (mathematics) Core dump Flow separation Buffer overflow Software bug
Point (geometry) Code Multiplication sign Cartesian coordinate system Code Number Data mining Casting (performing arts) Spring (hydrology) Process (computing) Computer animation Right angle Whiteboard Library (computing)
Logical constant Dataflow Functional (mathematics) Link (knot theory) Code State of matter Multiplication sign Parameter (computer programming) 2 (number) Element (mathematics) Optical disc drive Computer configuration Integer Data structure Data conversion Error message God Interface (computing) Forcing (mathematics) Bit Total S.A. Line (geometry) System call Electronic signature Type theory Data mining Subject indexing Vector space Personal digital assistant Order (biology) Statement (computer science) Natural language
Radical (chemistry) Information Code Oval Factory (trading post) Feedback Letterpress printing Whiteboard Cartesian coordinate system Error message Symbol table Writing
Information Block (periodic table) Code Content (media) Variable (mathematics) Theory Number Data mining Array data structure Computer animation Text mining Right angle Local ring
Logical constant Inheritance (object-oriented programming) Code Namespace Weight Multiplication sign 1 (number) Demoscene Connected space Data mining Computer animation Personal digital assistant Different (Kate Ryan album) Hierarchy Program slicing Self-organization Endliche Modelltheorie Object (grammar) Spacetime Social class
Logical constant Information Inheritance (object-oriented programming) Code Projective plane Variance Line (geometry) Symbol table Computer animation Single-precision floating-point format Right angle Iteration Object (grammar) Endliche Modelltheorie Row (database) Social class
Functional (mathematics) Goodness of fit Bit rate Structural load Order (biology) Right angle Instance (computer science) Object (grammar) Directory service Symbol table Library (computing)
Information Right angle Natural language Instance (computer science) Social class God
Point (geometry) Functional (mathematics) Game controller Computer file Code State of matter Source code Parameter (computer programming) Metadata Computer programming Software bug Computer configuration Different (Kate Ryan album) Error message Social class Physical system Interface (computing) Instance (computer science) Line (geometry) Uniform resource locator Process (computing) Video game Right angle Object (grammar) Fiber bundle
Bytecode Logical constant Point (geometry) Axiom of choice Computer file State of matter Code Function (mathematics) Automatic differentiation Programmer (hardware) Mathematics Semiconductor memory Single-precision floating-point format Macro (computer science) Physical system Multiplication Information Key (cryptography) Electronic mailing list Instance (computer science) Line (geometry) Variable (mathematics) Symbol table Compiler Type theory Hash function Chain Right angle Natural language Object (grammar)
Point (geometry) Beat (acoustics) Information Code State of matter Block (periodic table) Keyboard shortcut Expert system Maxima and minima Drop (liquid) Instance (computer science) Variable (mathematics) System call Arithmetic mean Computer animation Network topology Touch typing File system Right angle Utility software Object (grammar) Table (information) Local ring Social class
Point (geometry) Web page Slide rule Dataflow Statistics Interpolation Code State of matter Multiplication sign 1 (number) Set (mathematics) Water vapor Temporal logic Client (computing) Mereology Computer programming 2 (number) Product (business) Frequency Latent heat Bit rate Semiconductor memory String (computer science) Speicherbereinigung Error message Mathematical optimization Social class Key (cryptography) Information Interface (computing) Feedback Maxima and minima Bit Instance (computer science) Line (geometry) Cartesian coordinate system Variable (mathematics) Data mining Computer animation Hash function Charge carrier Right angle Whiteboard Object (grammar) Quicksort Communications protocol Window
Point (geometry) Ocean current Divisor Computer file Code 3 (number) Line (geometry) Directory service Regulärer Ausdruck <Textverarbeitung> Graph coloring Kernel (computing) Vector space Whiteboard
Module (mathematics) Point (geometry) Functional (mathematics) Wrapper (data mining) Plotter Multiplication sign Sheaf (mathematics) Bit System call Metadata Number Kernel (computing) Computer animation Single-precision floating-point format Network topology Interpreter (computing) Object (grammar) Window
Computer animation Information Code Multiplication sign Statement (computer science) Bit Right angle Line (geometry)
Code Source code Memory management Sheaf (mathematics) Line (geometry) Instance (computer science) Variable (mathematics) Entire function Product (business) Optical disc drive Computer animation Positional notation Single-precision floating-point format Video game Right angle Object (grammar) Cycle (graph theory) Codierung <Programmierung> Resource allocation Window Spacetime
Computer animation Multiplication sign Error message Social class
Arm Line (geometry) Whiteboard Social class
Computer animation Code Software developer Instance (computer science) Variable (mathematics) Social class
Point (geometry) Computer file Code Ferry Corsten Multiplication sign Mereology Computer programming Number Product (business) Mathematics Social class Task (computing) Condition number Area Information Block (periodic table) Keyboard shortcut Line code Sound effect Hecke operator Line (geometry) Instance (computer science) Variable (mathematics) System call Data mining Arithmetic mean Computer animation Interpreter (computing) Statement (computer science) Object (grammar)
Point (geometry) Dataflow Functional (mathematics) State of matter Code Multiplication sign Product (business) Single-precision floating-point format Cuboid User interface Area Compiler construction Dependent and independent variables Electric generator Information Mapping Projective plane Bit Line (geometry) Software maintenance Variable (mathematics) Compiler Type theory Word Arithmetic mean Computer animation Blog Right angle Buffer overflow
but mind you might we OK so it's 30 soaring it started so high and this is practical debugging if you're here for some other thing then I'm sorry and the airline had the book so I debugging in Ruby it's fun the 1 thing this is that
happens again stack traits yeah stack-trace in what you do as we co-workers in this is the
best response that I got usually curse audibly frightening my co-workers that was the best I got and and then there was silence in the slack channel from the the solid 2 days the and then someone asks about way out of something else completely different and I think this is actually a kind of a good of reason for this talk people don't know how to debug really and they pull in tools they pull in all kinds of dependencies the pull in all kinds of things that the people usually don't need I you you get what you need and when you download really so that standard practice when you have a question note to do what you do you remain calm and you ask what's a
core do this it's stack overflow driven development for hashtag WUS the arm and several forces you to think this is to use prior and says by bug but 2nd Fold really likes to suggest using these tools the suggest it all the time use
prior use prior use strike ISIS like this 1 this is use b and in the 1st comment is prize more efficient than I really have to because I guess I don't know I more the story at the end of the day if
people want bug-free code they don't care how it got that way you can you can use I don't care doesn't matter but and you don't itself pointing device it is on is actually really hard for me I live and die by winter I I look you guys are like that knowledgeable tend to be but I just love clean efficient syntax really don't care if it's functioning correctly I want to look good they just want to look good and that so I have problems because when I'm debugging all that code is going away and you have the freedom to say what it doesn't matter just delete the code it's going to go away anyway and so you can do all kinds of crazy stuff but and so you have to give yourself you have to get over the fact that the codes going waiting to everyone and my point giving this talk my whole thing is it through standard library has every tool you need to debug effectively you have right you can use prior I don't care if use pride feel free it's wonderful on the other side that there are tools that are available to you that are criminally underused and so on you know walk you through a couple others the point of this talk is not to give you every single possible tool to solve every summer possible problem the point this talk is to give you the diving board stick to show you the places where you can start year journey through debugging processes and to walk you through a couple of tools that I use pre-standard spring pre often to to solve these problems so 1st West new cast yourself and 0 I'm sorry backing up I needed an example application and just to debug over the course this talk so I wrote a little minesweeper that is enhancement minesweeper yes no maybe OK on a show to lie down time I so and
here's it's a it's in Ruby can everyone see that kind of maybe I'm you like click right and then you can tell me where the mines are as you talk about my and then you lose says you lose and then you can do the same thing I am I allowed you to specify the with the high number of mines so as 1 so you should we should be fine and then but a thank you thank you come in here and in other salient as I we click from and then it says you win but they're ago much better what are the
odds right what are the odds I could never tell know itself and so had this talk goes pretty quickly has a lot of code examples in run pre quickly but don't panic all of the examples are up on the get every there'll be people and afterwards he patented now and in and you can go back and review all of them and gives you tons and tons of links in time and the preferences so I don't start scrambling but I'm gonna go through these and examples frequently so the 1st question asked what kind of problem solving unedifying 3 kinds of problems that were work through the 1st is going to be interfaced problem seconds and the State problem there's going be a flow problem so interface problems 1st our problems interface problems occur and you don't understand the dependence structure of methods for constants methods have structure they have a return value there's is a tight the have worsened with multiple types they have parameters they have the order of those parameters that the types of those parameters all things like that constants have methods defined on them they have the ancestry they have descendants they have all kinds of things so interface problems occur when you don't understand the pen and structure of methods a constant you have to know these things in your code here making certain assumptions every time you call functions or reference accounts them in the scrums answer questions like why is this thing no it is like the most common thing that fine no undefined method blob love for Neil so fall walk through that why can't I call the method that i want well constants I can reference Watkins Southwark seen do 0 god 0 god what is this the gem even doing I into my affection I came here so the 1st question why a is the thing now so when the mine super-code we get
this no implicit conversion from nails integer right here here so what's going to school little bit and the error is on this line and it says no was a conversion from their integer so neighbor is milk is it's trying to cost that into an integer the can reference inside of array for and so we say OK neighbors Nelson neighbor is an element of neighbors wise neighbors have nail in its we go to this Neighbors for Neighbors force defined here neighbors for calls index for index force defined here a pretty quickly can problem that joint return meal if statements and and you know while this is a little bit contrived the the neighbors for method assumes the integers were being returned the index for method does not have a signature now in Ruby we get death in other languages you might have option into work optional interim EB enter or whatever it's In this case a bit depth that is what you get and it's on you the onus is on you to take care of this type signature and its implicit it's not there you are treating a soft newbie to say death and you don't care what gets returned In most cases this is wonderful this is quick this is very very fast with you market and then later down the road you know year you get a honey better because you didn't take care of the whole type signature so in this case that take such a pretty easy we had not compact there it a organelles everything's great so basically if anything is ever notice at vector total light and moving right along like if I call
the method that I want so let's see we get this
error and we get this and this is a clue
rescuing method missing you might also get undefined method either 1 this tells you OK were trying to call something that doesn't exist so the first one factories and we control the board we get this bill status able method and this is where errors going from we have add a reader there in were like a we should be of all this thing because it exists I right so what they do so we add some debugging method with some debugging code we going here and recall the methods method that interview an array of symbols that can tell you everything you can possibly call where print that out with E P is a great method it's a spectively this but instead this right it's quick inspect considered you that I'm were eggs immediately you achieve the feedback loop as quick as possible writing on your application just keep running just get the information need immediately and finally we're gonna crept through the methods and try to find a method that we need a distant out that all the terminal so running the code we get
that's the 1st arrays theory were looking for the thing and 2nd raise all the methods obviously didn't write all these methods so clearly the scope inside of that block has changed we go back to our code we get body been information and we can find out that in fact self is changed in this block that kind of makes sense because including by the fact that text in greater numbers that we actually to find we take this lexical scope incentive Ruby has referenced local variables in the block was defined so we take that text mines mines left and content with move them amount the local variables and everybody's happy now this example thing to remember we use the methods method right found everything we need real quick the debugging excellent moving
on 1 of the conference I can reference this 1 is kind of fun because people
at people tend to forget that constant look up is not the same as ancestry instead of reading it's the different things so let's look at this example was we refactor got cells to have different hierarchy in recital Karen have these cell mine in the cell neighbor in this cell empty in around and take care of their own needs and whatever in this case uh so we think this is great and we go and run the code we say 0 I a slice constant mind Superbase to go back in your code and the tool that we're reach for this time is model that nesting model that nesting is a method that's going to tell you exactly what namespaces you have access to within this current lexical scope so if you run this code where to get minesweeper nets organ again we go back into this code what this is saying is that we only have references to the top of a conference which can always reference and the constants directly to find underneath the model namespace so in this case you go to that perseveration class so mind descends from base base is not mine Superbase spaces my supercell base right so do little refactoring move his eyes on in move that up right again and you get minus for minds it right so you can see from this code how you can now access the base class and the connections having get so what can this object scene
due this one's find so there's there's all
kinds of introspection tools that are readily available to you and this is just something that's a couple lines of code tell you everything constant that's fine the project right we do a couple things we can print out the name of a constant we can look at the constants right got Constance's method is defined and constants on models with them and we can iterate through them and we can call const get to get something by symbol will give us an object we can then iterate that recursively and get all the information we run our project it's pretty boring and it tells you 3 constants but you know you can do things like run on Active Record and get every
single Active Record constant variance probably not immediately available but parent what the value of this sense but being able iterate through constants frequently is very very useful especially when you're dealing with of reloading with loading with rails and something has been loaded think STI for you when iterate over the descending classes and all of them have been loaded this is very very useful for that kind of dividing we also
find everything we can call on an object being enlisted instance methods right this rate here is instance methods functions
going to give us an array of all the of of symbols that represent those methods making use even knowing that the local we can do this on a command line right that dash eyes in and the lib directory to order low-pass Archibald load path through the the best or can require it guess she's no evaluated and we get all this goodness we can do the same thing for instance methods that are
just defined on this class and not inherited same thing a private instance methods and the same thing the province method is that is the justified on this class all this information is available to you from the command line it's like 40 lines worth of typing for 40 characters were the typing try to get that with other languages it's not the easiest right this is quick introspection and and this is some of the fastest the that and get finally we get to my
favorite 0 god 0 god what is this genteel in doing I listening to this this
error message ambiguous option column and never mind the fact you probably can't spell but were to go with this example for a minute and let's go to so we will we could do we could go to the code from our side we can also go to the code from the the vendor genocide to really do that so 1st line the control we go in and we find OK this is actually calling for member of lexical scope example earlier the T cable grid method so go and work for me and minus say a a skip that ck method grid and then the source fiction source location method instance method that will give you back a method objects the method object then has metadata the on it you can get right source location is going to tell you OK this is the exact file on your system where this where this function is defined and this is the exact line inside of that files so you can go quickly and find the we find OK where what's this is this is defined here this is calling at the TKE grid method so it's going get that repeat the process the only difference here is that finances method is class methods we use the method method instead of the instance method method you tired of hearing the method here I am making repeat the same process we can go into the code we see OK this is what it's actually doing right have tried do this for the job enjoy yourself this is we know that the error comes from this line and we know that programs is being passed into this so let's just go ahead and print out parameters and hopefully at
this point it's now become evident that column is misspelled and you can go in your code and fix the bug yeah the at the end of the day when you're done messing with all of your vendor gems you don't want to leave them in that state bundle exec gem pristine will restore that to this state that when you download the generationally you'll dashed ashfall Nova just clean your whole your whole life out so the lessons learned from interface problems
account for a return type you don't have a compiler you don't have something telling you OK this can return these kinds of types and you need to go 1 by 1 take care of the of sealed traits here right account for constant method look up you need to make sure that you know what lexical scope here and you need to know make sure that you know what you can reference on the other side of that take advantage of constant method introspection you have these tools at your fingertips you can use these very quickly and we don't use them you're giving up 1 of the greatest assets you have for having chosen Ruby your language choice and finally take advantage of affected gems are byte code right they're not they're not compiled you can do anything you want to them now you can go and delete files and see what happens if nothing else you can use them as an educational opportunity just to go and see what kind of problems they were solving and see how they solve those problems and you know and this is 1 the best ways to learn Ruby you have all those files already downloaded to your system they're right there it's great so use them the problems so say problems say problems occur when the assumptions you made about the current so the programmer incorrect that might seem overly generically broad what I'm basically saying here is that the internal state of every object in your system that's living and breathing inside of your memory as it's been allocated what assumptions are you making at each point code that may not be correct they answer questions like how does this value change at this point what is then initialized at this point and how many objects are allocated in this method or within this lexical scope so 1st 1 how is this value chain to this point the going this good we
say OK but not Texas changing in the States changing something that we don't like it's changing to some and also bars something that we that we don't know why we can go and figure out exactly what's happening very very quickly in modern ads introspection code here figure out exactly how so we're use the instance variables method that goes lists an array of symbols again defining every single instance method that's been initialized on this object we can then map over that use instance variable get to get the value we can then create a hash so that put out command line and finally we can get the current state of the text and then use a text and did all that information when the running we get a harsh with a key is being instance bars the values being the actual value of those and the state being output while this may seem relatively trivial just to get this information that was like 6 lines of code to tell you exactly the speed of your object and was payments to put in right I used 2 methods that I had to know about instance methods and inspir instance variables an instance variable gets that kind of information is relatively easy to remember right you don't need to think about some kind of introspection EPI with multiple objects in trying to use some kind of compiler macro to try to get your information available to you this is very very quick was initialized at this
point a similar last 1 was city-gate undefined with account for no class we go in your are code in the C CIA cells is no wise cells no Camille for 2 reasons 1 we forgot to initialize it or it wasn't yet initialize at this point 2 it was it was already initialized and it got mutated somehow and now the l either way it doesn't matter for state problems with this interested in finding out exactly the current state of this code so we go in and he's buying that higher B might look similar to bind a prize it's very so it's like the same thing except it doesn't have like the LSA this C D you're all the stuff the major tree objects like file systems that are kind of but this is brand new Mobutu for cannot using a ship for you should use your B 2 4 so 1st of all summer binding binding is inside the current lexical scope of any kind of block considerably it can tell you the table of local variables in the call stack as well as a couple of utilities and other much I'm a B right is what happens when you're getting the rebels the so when you require b i b adds an IRI method to the binding class which will then drop you wanted to go you run this code of the will shorter but it's drop you into desire beat desire be consul right at that point code you can introspect and instance variables you can determine that in fact cells is no a going complete this whole debugging example in a minute but suffice to say at this point you can use binding guarantees get all that information very quickly how many objects are
allocated this point so I was going to include this example just because it's such a minimal touch on GC but I'm gonna do it anyway so just because it's good to know that you have these tools available to you I by no means kind of UGC expert there are so many people more qualified to speak about this but I'm going to just kind of give you the beginner's guide to what you need to know I so let's say we have this
code he ends status that taxes getting updated and we have determined through massive amounts of profiling are part of this method is slow we don't know why it's slow and so we're going to do a little bit the profiling our own for just a specific method Cereno crater board now before I add the rest of the code of the slide remember what I said earlier that you don't itself points and debugging this is going to be egregiously bad code that you should never use then so were a clear board and I don't want you with the teacher status particularly will some disintegrate this struct and instance the bell that in there then recruits cells and other cells tk buttons minute create some buttons see what is going on does not just like hurt your eyes a little bit rate amended for doing bad things to review and but it's OK were we all working final exam what's going on so it's add some code over and say OK ge this is your window into the garbage collector is can't tell you what it's thinking about what's measuring what it's it has done and everything the stat method is any of us back a hash that can give us the current state of the art collector the total allocated objects uh key within that Asch is going to tell us exactly what we've uh how many objects of an allocated and finally if we look at this code were run updates that is 10 thousand times and see what happens if we run this code and we get 70 thousand 1 so thinking back ran this thing 10 thousand times so 7 objects to being allocated per method call the you go back in your code and this is the block because you're controlling for that sort of this is the the 2 lines a get executed c can do a couple things here and I'm going put the all carrier here normally this kind of like intense GC optimization memory optimization is not useful you have bigger fish to fry your pages taking 3 seconds to low this is not going to help her of that being said it's a good example in it for say this is like the most critical path like you have to know how many mines are left at all times like just 10 million clients connecting and they have to know and I guess you can do this and so it is a OK but we don't need to select and and how we can count and we don't need to do string of concatenation making interpolation that we right again we get that other 1 we deleted too objects that's a very minimal GC example it's just to show you that right GC you have that kind of introspection available to you at the that time lessons
learned from state problems take vendor rich quick feedback loops and flexibility I was able in since the val status and that button in their in there 2 trucks and it didn't matter because it's not checking the EPI it's not checking what you conform to it's not checking the have some kind of marker interface a protocol saying OK these objects can be substituted for these other objects in your abilities into your program see any point in is when you're strongest tools and debugging right you can go into your code and run this at any point you can put it in your code anywhere inside of your whole application can get this information quickly so glow problems our last class of these most serious ones these the ones that you hit in production you the ones that honey Bateson's union all 3 and flow problems occur when you don't know how a reinterpret got your left implication codons associated state a bit of a mouthful of water that basically saying when you have your application code and you say OK at this line specifically I have an error and I have no idea what's going on you know how it got there where it's going the object inside that state where they came from where they're going so it answers questions like how did the interpret get here where the interval go from here where is this object has object it here where is the subject the mutated and finally where is this instance variable set right these are all temporal problems Caesar having to do with over the course of a longer period of time so there necessarily apart having interpre get here for so this one's pretty easy to solve we look at
this code we say OK it says we win the moving up a logic across in says we went after the 1st click we can find out how to do that really quickly we can say OK puts caller colors method from kernel going to tell you the stack trace up to this point we don't we run this code and gives us all this it tells the whole backtrace that's great that's pretty good but it's kind of frustrating because now we have all this code that we don't wanna look at more because we still have all of the Exxon Gensler get that out of there
real quick cleaner without pulling a 3rd party jam rejects but this is a new rejects it creates a regex from the current working directory from the directory in which this file is defined and we can grab through color like that pretty factor that is clear we go on re on it and get that those are just the lines in our code that executed to get to this point right he created I it might super stop was called they're called board that search that calls that creates cells the cells called copper minor called update everything but that's a vector X interpre
go from here this is very sad plot the hammers this section is a little bit harder so we have the pull up the bigger tools so this is our very start
and say OK from the very beginning we wanna know everything we don't know anything about the skull base this was the work of tracepoint a friend tracepoint is a module that will walk you it's a window into what the interpreters seeing right it's actually can be a wrapper around the set trace func bleak and kernel which is a little more functional so this is like another trying to way of looking at that and so that's trees point uh the new call is gonna say OK every single time Ruby function is called execute this block and give us this TP object that object has certain metadata on it's like half of my number if we going run this code and final enable we going around this kobe get all of this
information right we can walk through line by line as this thing is going again 1 clean that up this little bit so those go in and that statement
that says basically the same thing as we did last time we go run that code again in it says exactly lines of code that we've defined can walk through right this is quick information again just going to show you exactly every single line that you control that you can change it has executed already how did this subject get here
I another hammering a bust out see we have this the odds of answer odds of button and that's an instance variables that were in a certain that's coming in we have no idea where came from but the object space to object space is a window into the Ruby heap to window into what's been allocated I and actually it also allows you to access when these things get deallocated I a couple things you can do with this and were into real quickly that will section the bottom right has acquired that's 1 reason I put at the bomb used the require that 1st to make sure the object space noses trace notations can obviously dormitories that production so but the single allocation source file allocation source line we put that information out and we can find exactly the lining code with this subject was created we go around that we get bored out RB 949 we go and we find out OK this is exactly where itself right you can go anywhere encode find out where all those objects came from and now on the other side of the where
is the subject being mutated we have an object encode we know exactly where it came from we can now find the entire life cycle where is the subject being neutered and the easiest way is actually surprisingly simple so
undefined method like for no classes go in and
say OK we have B cells we know they were initialized correctly and 1 of them is no wire they now so we go here and clearly something is mutating the cells are a something is turning it over the course of its going from its birth to where we are trying to access it so that freeze so that freezes gonna say OK any time this a would be modified throw an error immediately when run that instead of getting
undefined method click for no class which is several lines deep we gets can modify frozen array board out RB line 32
we go and we see OK somebody was reading that bang methods are more performance they got really excited and they said OK for always bang methods and that's bad arm and it can be reflected via this cells no longer gets modified and everybody's happy finally last
example now this last example is a the trickiest 1 so stick with me but when does this instance variable that set
and undefined account for no class we go in your code this is the previous example we said finish right this is where we left the code now the problem here is that cells should be set but it's not so let's make it set there assume that's the developer who did this was not an idiot but it's it's a good assumption to make in general guy the guy were girl who made this was not an idiot and this code should have worked they were soon the cells initialized so it's going
on OK we're on it and says 0 mines left but the program run this is good means that we can you know keep working back and work only say
OK now we define the line of code in this file were this instance variable would have been set so that we can change build status will be after that so sparse our old friend tracepoint this is getting complicated I it's not as bad as it looks 1st of all this is going to give us this block these this cheeky object at every single time the interpre hits a new line code it's gonna enable then as the safe for work if some condition that will go through put out the tasks that you're at and the line number minus 1 the reason were saying line number minus 1 is because they were and try to create an if statement that says OK if cells changed then the previous line must have changed the 1st part of the if statement are we within the same file this may not be relevant but for us it's easy because it's an instance variable and assuming you're not sitting instance variables on objects from other classes don't ever do that but we can assume it's within this file next but TP that bind died you so that classical legal that class what the heck am I doing there I so binding directly valve right when you're within the tracepoint block when you have a T object you have access to the binding at that point in code you can access all the variables that that binding could have seen anything this call you know on it remember how you don't quote you don't production please don't call it on production you can do that and debugging you don't itself points debugging it's going to go away anyway the so the point of this line is because earlier remember we had that lexical scope issue were inside of that block that's still inside this file to you make sure we're still value in that code within this class and finally this is the money 1 were create local variable that we're now have access to within this block area say tp binding that you the instance variables cells not equal the cells that is to say if this instance variable changed then we would know about it and 1 immediately exit nest give us information so you and that's we get we a line of code and could file in which that instance variable changed because there's 1 line if you go back to this code this is 9 lines of code 9 lines of code to attached to the Ruby interpreter walking through every single line and evaluates evaluating instance variable and tell you exactly when these things changed we go hand in it turns out this is valuable to these effects this is the line 1 change we do that having sex so
lessons learned from flow problems for large projects should requires effort follow the flow this is just a thing with larger project is going to be harder to walk through the um this actress you know your have thousands and thousands of lines you need be very very careful how you clean it how you walk through on the other side for new projects actresses are easy to generate follow a point of saying this is is going to be easy at the offset we know this from rails right we have generators we have a quick and easy 15 minute blog tutorials it will get you up to speed very very quickly it only becomes far down the road so all that is to say were taken some trade offs from user B and move debugging really were trailing from were treating compiler niceties for introspection write compilers will tell you when you haven't they taken account for every single type this in returned from functions on the other side that Ruby is going to give you the ability to introspect on any point code every single variable of a small constant every single state of anything that's going on and that information is available to you very quickly if you don't use that as a tool in your debugging then you're giving up 1 of the best advantages of using review were trying out of the box speed for flexibility right if we had taken the out of the box the and then we would not have been able to take that no status struct and stick it in for a T label would trade those things out because the compiler will at you it will say no I need to ensure that everything is correct before I run and finally we train maintenance cost for start costs this is overflow problems this is for when you're trading off the fact that it's going be very easy to get to market to ship this to production and down the road it's only a little bit harder to maintain In other words the user interface problems for you know the compiler versity introspection found by the responsibility of the State problems in mean costs across these a flow so the next time someone comes up to you and says you know Rabi's dead don't use repeat it and say you know actually you know undergo chip map production and I sleep find and enjoy effective that area thank you thank there're if the
rewards and so