Good morning again at the point where we left off last week we were talking about the difference between probability and probability density. How probability can be the theory of probability or actually the whole concept of probability can only be applied to where the number of outcomes is finite and countable. Whereas you need to go to a concept like probability density when the outcome is on the real axis. So, any real number between some limits is a possible is a possible choice for an outcome. So, without going much into the theory and this is actually a an unresolved question in space we will for now assume that drops can be any size between some minimum size and a maximum size. The minimum size could be 0 maximum size could be infinity for all we care. But we will just assume that they do have some finite limits and even otherwise nothing in what we discussed the other day is going to be different as long as there are some limits on which these two on which all the drops exist. So, we will continue that discussion and start looking at sprays in some detail. So, we know that we define a pdf. So, f of x is a function and f of x times dx is the actual probability of finding the value in the range x to x plus dx. So, that is if this f of x is defined in this fashion then f of x is called the probability density function. So, this we looked at the case the other day when we looked at a circular hoop and we said what is the chance of one of the angular positions showing up on top and really speaking the probability density could be any value. In fact the probability density does not have to be between 0 and 1 because this is the actual probability of any set of outcomes has to be between 0 and 1. But the probability density itself can be any number we will see in a short while. In other words the function has no upper limit on the values and it can take as opposed to probability fine. So, applying this principle to sprays what sort of intuition can we bring to the forms of the function that this f of x should have in a general spray. Let us start thinking about that for a little while. So, if I will now use a slightly different notation I will say p of d p of d is the probability density function of say a drop diameter in a spray and I will be even more specific we will just say at a point for now at a spatial point. So, this is sort of the easiest to understand we will start with this. So, if I did my temporal sampling. So, I was sitting at one point in the spray and I sampled every drop that went by me and I accrued statistics of a large number of drops and we discussed how to construct a probability density function from a large set of such drops. So, I did that and I got this function p of d p which is a function of d what sort of functional forms what should the graph of p of d look like. So, if d is generally speaking what would you expect the graph to look like let us draw some simple features the first sort of physical limitation is that the drop size cannot be less than 0 correct. So, on the right side on the left hand side of the graph the probability density clearly has to be 0. Now, can I find a drop of size 0 there is no such thing as a drop of size 0 the drop is of size say some minimum possible size in the spray. Now, we will see that in we will see may be in a couple of classes from now that that number is actually a number that is much greater than 0 much in the sense of atomic scales. So, if one molecule of water is a few tanks from the drop of a drop of water the smallest drop of water that you can create using a spray process will be much bigger than this size and there are reasons for that we will talk about that, but let us for now say there is a d min below which I do not expect to find any drops what about a d max let us talk of the limits. If I take a typical spray we looked at the perfume spray in some detail there is a hole through which a hole on that perfume can through which drops are delivered into the spray right. Now, is it reasonable to say that I there can be no drop bigger than that hole diameter. So, in other words if I have an injected diameter I cannot produce drops greater than that injected diameter strictly speaking I am wrong I can produce drops greater than the diameter if I have other processes going on later on. So, if two of these drops want to come together and coalesce I have no reason to prevent that from happening. So, technically speaking there is I cannot say that I cannot find drops greater than that size all I can say is the probability has to continuously decrease as the size decreases as the size increases. So, as the size say for example, if this is my orifice all I can say is as I go further away from this d o this probability has to somehow decrease. So, that is going to have to be the form of the graph going away it has to asymptotically reach 0. Now, this is as far as our understanding without really having a spray in front of us no data nothing say now can I actually allow this graph to come intersect. So, if I is this is this a reasonable possibility that the graph will intersect this axis beyond that the answer is that there are no drops greater than that particular size all I can say is I cannot make this generalization for every spray. So, at the moment whatever we are saying we want to leave it sufficiently flexible to be able to apply to every spray that is sort of our approach for now. So, at the moment all I can say is that this has to asymptotically approach the diameter axis. So, the probability density asymptotically becomes 0. What about the shape in between this and this? Now, first of all I know the shape of the graph near d min it has to increase that is the only way it can go probability density also by the way cannot be a negative number right just like probability. So, probability density is a positive number with no upper limit lower limit is of course 0. So, with these as a thing now I can there is only one possible general shape for this graph if I say this is the starting and that is the ending there is only one way the graph can go which is if the probability density function is a continuous function and differentiable everywhere this is one possibility which means that there is one point which is the at which point the probability of finding a drop around that point is the maximum this is not the average drop size. So, we will look at that in just a moment this is the what we will call the most probable drop size. So, you can sort of just although this is not a widely used way of referring to it we will very soon make the distinction between average and this most probable drop size. But so essentially I have this function p of d which could be which now has these general features if I want to write a mathematical equation that fits this there are many different mathematical forms that are possible that initially increase and then decrease with or without with d min being 0 with whatever it is there are many mathematical forms that are possible as many mathematical forms. So, many proponents in the literature for those mathematical forms meaning this is there is at least like 5 or 6 very widely used forms of distributions that people claim are fundamental to sprays and each of them has their own valid reasons for those claims. So, this is but this is the shape that is generic to all of those mathematical forms we will come to that in the next class. But before that I want to define a few parameters that are not dependent on the specific mathematical form. The whole point is that ultimately if I say what is it that I have achieved by defining this I have defined the spectrum of drop sizes that I can encounter at one point in the spray over some period of time how useful is this very useful because I now know what the spray looks like from the inside like we said before right. But in many instances this is too much information I want to condense it if I have to now move to another point I have to find this all over again for that other point. So, I want something that is more manageable and therefore, going from this full this is the full probability density function we want to define we want to define what are called moments of the distribution. The simplest moment to define before we go to defining moments I want to make one obvious point one more time that if I take any of these the area under this the area going 0 to infinity of that probability density function in d d it is a little tricky, but I cannot help it I can probably make the point over here as well just to sort of because integral 0 to infinity f of x d x. Because f of x d x is a probability of finding the draw finding the point in the set of outcomes x to x plus d x if I do this addition over all the say all the x that amounts to integration and that is what I get this is the only requirement of any probability density function all right. So, I now want to define a set of moments of this the simplest is what we call the average diameter you know I will move away from this d d business and I will say moments of a p d f f of x and I will define x is drop size in this case first constraint is that f of x d x equal to 1 and then if I define a mean drop size let me write down what this is. So, the probability of finding a drop in the limits x to x plus d x is that so that probability multiplied by the drop size itself added over all of the various sizes possible is what gives me the mean drop size. So, just to sort of illustrate the point if I have let us say different sizes x i x 1 x 2 dot dot dot some x i x n I have n drops of sizes then the mean drop size for this sample we all know would be x 1 x 2 that all you are saying is that each drop has a probability 1 by n. So, you are essentially multiplying 1 by n times x 1 plus 1 by n times x 2 now if some other if x 1 and x 2 are the same for example, in this set then that would become 2 by n x 1 2 by n x 1 because your 2 drops of size x 1. So, essentially what we do by average is the same as what we are doing in the sense of probability density. Now, we are going to get used to this notation of using the angular brackets to denote mean. So, this is often called the first moment I can define any moment of this distribution by doing exactly that. So, if I take x power p, p could be some number then x power p just like if I have drops of size x 1 x 2 x 3 etcetera then I can define if I say what is the average surface area of these drops. If I choose p equal to 2 in this case that gives me the mean surface area barring some factors like pi or pi by 4 etcetera you know that does not I mean we are not really worry at that level of detail and we are not concerned about that also usually. If I choose p equal to 3 what do I get I get the mean droplet volume. So, I can define any of these moments you know I can define a p equal to 4 now what would that physically mean I do not know, but I am sure there is a reason to define it and people actually use it will see in a moment one such use. So, what we want and by the way p equal to 1 gives me the number based average. So, if I said p equal to 1 that is simply the mean diameter I can define an average called x p q from this same f of x as the following. So, if I say x power p f of x d x integral 0 to infinity divided by x power q f of x divided 0 to infinity if I raise this whole thing to the power 1 over p minus q. Let us think about what this is x power p this is the p th moment and the numerator is the p th moment the denominator is the q th moment of this same distribution. If I take the ratio of the two that gives me sort of the value of the p th moment in comparison to the value of the q th moment that is essentially what ratios are, but the funny thing is if x has units of say micrometers or millimeters x power p has units of millimeter power p x power q has units of millimeter power q. So, this ratio will actually be a dimensional quantity of units millimeter power p minus q which is like a funny unit I do not want to deal with that. So, if I raise this whole thing to the power 1 over p minus q that gives me something in the units of diameter. So, this is also some moment of the droplet size distribution and is a diameter and it has the same units as diameter. So, I can now relate to it physically that is the only reason to do the power 1 over p minus q. Let us look at some simple possibilities. If I said q equal to 0 and p equal to 1 we get our first moment p equal to 2 q equal to 0 gives me the second moment just the way we have defined, but if let us say p equal to 2 and q equal to 1 what do we get raise to the power 1 over 2 minus 1. So, this is essentially the mean surface area divided by the mean diameter. So, going back to our original this thing I want to now write everything in terms in this p q notation x 1 0 is the mean diameter you can see that x 2 0 actually let us be clear about this I am sorry we will say this is the mean. So, just simply a number based diameter because I am just doing an arithmetic average of all the drops that is essentially what x 1 0 is if you go back look at this notation here of x p q. If you look at this notation of x p q the numerator is x f of x d x which is just like saying I am doing an arithmetic average over all the population of drops that I have x 2 0 is the mean surface area based diameter and just for the sake of equivalence I am going to do a 1 over 2 minus 0 to make it look like a diameter. So, I have taken the mean surface area in the spray at that point and divided and taken the square root essentially to give me back a number that has units of length of size likewise x 3 0. So, these are all diameters that is the point to note here they are all they have the same units as diameter, but they are all different physical quantities because now the x 3 0 tells me sort of their average volume. So, it tells me where the volume is concentrated another x 3 2 I want to write this out. Now, this has a special name this is often called the Souter mean diameter. Now, when you see Souter mean diameter in the literature they do not use x they use d for diameter I am just using x because that is easier to do d x in this kind of notation, but imagine d 3 2 you will see this written very often d 3 2 is this Souter mean diameter at that point in the spray. Now, this is very widely used as a measure of a spray now remember it is just another moment of the p d f that is how you get the Souter mean diameter, but what makes this number so special it is essentially the fact that the numerator is the mean droplet volume and the denominator is the mean surface area. So, both those quantities being physical if I want to imagine a situation where I want to release the volume contained in a liquid drop into a gaseous medium it has to go across this interfacial area. So, any sort of a mass transfer problem that is the simplest to imagine, but it also applies to heat transfer any sort of a interfacial transfer problem involves volume because that is your source of either mass or thermal storage in the form of rho c p rho v c p or m c p that is the total thermal inertia or thermal storage capacity of a given drop. So, that m or rho m or v is an indication of the volume in the which is in the numerator and the denominator is what the mass has to go through the total interfacial area that is available to a certain given drop for that mass to become let us say evaporated or heated or whatever interfacial process the has to happen. So, this is essentially also referred to as the mean this is essentially like a mean volume per surface area for the drop or 1 over this is the mean surface area per unit volume you know in our very first lecture we said the whole objective of a spray is to increase surface area here is a direct measure surface area of what surface area of a given volume of fluid. So, here is a direct measure of that increase in the surface area per unit volume. So, if you in some very crude way take 1 over this and multiplied by your volume that you had in that 1 with that automatically gives you the total surface area that you have generated. So, that is this is the this is one of the more commonly used measures another sort of commonly used measure is called the debrock your diameter notice that if p minus q is equal to 1 and automatically you have units of diameter. So, this is used in cases where in like spray drying where evaporation is important. So, it is like x square gives you the surface area and x power 4 is a moment that is related to it. Although it is really speaking this outer mean diameter is what you will see reported in many many different applications. In fact, some of this theory of you know handling distributions came about even before they had the idea of characterizing sprays using distributions. The first origin of idea of distributions came from pulverized coal when power plants when coal fired power plants were being built the most you know some it was figured out that the most efficient way of burning coal was to pulverize it to tiny particles and then burn it. So, I now had to have some measures of the of the you know what the result of my pulverization process. So, all of these distributions all of the moments that you see here d 2 0 x 3 2 or d 3 2 were all developed for particle sizing in coal in pulverized coal applications and they are just as applicable for this case as well. So, here we have I have what I am claiming now is that using let us say I will start to number this just to give you a quick count of where we are let us say there is 1 there is 2 there is 3 I will also add x 2 1 here which is the mean surface area per average drop. So, how much so that is like a another measure of surface area per average diameter there is 5 and there is 6. So, we are now somehow claiming that instead of giving you a whole pdf if I give you either these 6 numbers or even a few of these 6 numbers you can have you can get a reasonable estimate of what that distribution will look like without really having a full functional form at your disposal. Knowing the limitations that we started to talk of if I just tell you an x 2 0 and did not tell you it was from a spray really could not make much of it. If I tell you it is a if I tell you it is a drop size distribution then you already have all this intuition that we started with that the drop size distribution has to tend towards smaller and smaller values as you go forward as you go towards infinity it has to have an almost finite cut off although d min can be 0 there is no reason to not be 0, but we usually find it to be a finite value and it has to reach a maximum value at some point and then drop off. This intuition taken alongside that number now has now tells you some shape of this distribution like for example, I can clearly say I mean the simplest intuition to start with is to this would have a greater x bar you can already see that. So, if I just tell you x bars of two of the spray at two different points you can imagine what these distributions would look like they have to be something like this. Now spray themselves spray itself is not a one dimensional entity I am not talking spatial dimensions or time the set of drops at one point in the spray are characterized by more than one variable we looked at a whole list of variables in the very first class. So, I could have diameter be a characteristic temperature is another scalar characteristic concentration is another scalar characteristic velocity is a vector characteristic I can treat the velocity as being let us say at most three most three more scalar characteristics scalar properties. So, I could have all these scalar properties of a drop apart from the size itself. So, if I want to understand what the set of drops look like in that space I need to go to multivariate distribution. Say for example, I will simply I will take a simple case of drops in a pipe let us say they are all moving only in the x direction there they could be of different sizes, but they are all only moving in the x direction. So, I have a velocity u. So, if I do what I told you before if I sit at this location y y or b b I will just call this b b if I sit at b b and sample all the drops going by basically measure its velocity and diameter I have n drops I can sample the diameter and velocity of every drop I can now construct a pdf in two dimensions in d and u. I will put this in quotes using the word dimension only to show the idea that I have two orthogonal directions in which pdf could vary the function itself is a function of two variables. So, essentially it is a two you have two independent variables in the argument list of the function which is d and u. So, if I will try to draw a quick cartoon sketch of this.  So, I could have in this direction it could be something like this in the other direction it could be something like that I am just drawing sort of images sort of shadows of this distribution in two different directions these are all the I could have this surface in the in three d in f of d comma u is a function of d and u and this surface gives me the total it gives me the probability density in this two variables. Now, again all by doing this I only made the problem more unwieldy. So, I need to I am better of going back to my moments. So, I want to see if I can define some moments of this 2 d distribution in the context of diameter d being diameter and u being velocity. So, the simplest thing is to say that if I want the average diameter just like. So, let us before we go this far I want to rigorously define what this is can let me just quickly rewrite this in terms of x I think that makes more sense x is size u is velocity. Now, the mean size in this at that point is simply the integral of this. So, if I take this x f of x comma u d x d u this gives me the probability f x f of x comma u times d x d u is the probability of finding a drop in this in this range that in the set of values that that I have defined. If I do this two variable if I do this integration that gives me the mean value over all the sample of drops this is like just like an average thing except since I have a second variable of integration u I have to do it I have to do a double integral. Likewise, I can now define an average velocity and I can define all the moments that I described back then. So, I can define like a x 3 2 x 4 3 you know all of those that we defined earlier are also applicable except each one each term the numerator and the denominator would now be a double integral. Now, there is only one more additional physics that is introduced in going to two variables in the probability density function that is something we talked about in the end of I think two classes ago which is this idea of size velocity correlation. How do I understand this size velocity correlation that is are the larger drops moving faster than the smaller drops or vice versa or there there is really no relation between the two. How do we go about that the way to do it is to define an average velocity that is conditioned on the size.  So, this gives me and that times u gives me a mean value that is conditioned on the size. So, this tells me the velocity while x is still a function of the. So, if I take this and divide it by the average velocity this gives me a function of x because the numerator is not is a function of x the numerator is a function of x the denominator is just the mean velocity like we have defined in the past. The ratio of these two would remain a function of x and this tells me the average velocity of each x of each set of drops in the size x to x plus d x. So, it is like an average velocity of that population of drops and as it turns out if this is a straight line the if this average velocity is not really a function of x, but is relatively the same for all x that tells me there is no size velocity correlation. So, one way to another way to understand this is that I have this two dimensional function I want to look at two I want to see if I can split it up into two independent if I can separate the variables out. So, we will talk about this in the next class if I start off by saying I can do this that means the velocity distribution in the u coordinate is independent of the distribution in the size coordinate. So, this tells me that there is no size velocity correlation. So, if I can so both are equivalent if I through the first measure find that there is no size velocity correlation that means I am able to separate the function f of x comma u into this form. Let us quickly recap what we learnt today and then we will stop here. We started with moments of a pdf and then looked at multivariate multivariate distributions and along the way we built some intuition into pdf forms in sprays. So, pretty much every pdf you see will have that up and down and asymptotically going to 0 kind of a trend that we will stop here.


I be riding gently in my Bentley Seizakil Minanga shows off our 4.4m ride. Socialite Seizakil Minanga had the TLS in a hot mess on Monday when she took to Instagram to flex on the people with a pic of a Bentley, worth our 4.4m. Seizakil stated some of Mzanzi's most rich and famous and is no stranger to posting about the good life she lives. But even her biggest stans were left gasping for breath when Cis posted a pic of a slick silver Bentley Bentayga Speed. She got real deep, telling followers that she is riding gently in my Bentley, while you keep switching lanes. According to the company, the Bentley Bentayga Speed is the world's fastest production SUV. Car magazine said it retails for around our 4.4m. Seizakil's love life has hogged headlines over the last few years, with her penning a cute love note to footballer George Levis last year. The pair had dated several years ago but got back together in 2018. In her note, she called George her soulmate and best friend. When I tell you I love you, I don't say it out of habit. I say it to remind you that you're the best thing that ever happened to me. True love is finding your soulmate and your best friend.


At Ellis Brigham we take product testing really seriously, it forms a crucial part of our range selection and today we're out here at the ski industries of Great Britain ski test in Kutai, Austria. This is the last part of our range selecting, it's where we're going to decide exactly what skis and boots we stock in store. What I want to do now is pass you over to the brands so they can tell you about the key features of this ski, who it's designed for and what it's going to do. This is the Bell DC 72, it's for an intermediate to advanced ski who spends most of the time on the piece. With a double core technology and a shortened binding plate, this ski has a much more consistent flex pattern, making it really comfortable and easy to ski on no matter the steepness of the piece that you might be on. So it's perfect for anyone who wants to have a good piece ski but a dependableness that's not going to catch you out. So we're out in Tine in France, this is the Ellis Brigham ski test and this is the final part of our testing program. This is when we invite colleagues from all the shops to come out and join us, try the skis that we've ranged for next year, validating our choices, but also make sure that they've skied them, they know exactly what those skis do and they can give you the right information when you come into the store. So here's what it's all about. So this morning I've been out on the Nordic Abel DC 72s, second run of the day for me, the conditions at the top were nice and firm, softening it up and turning into a bit of spring snow slush at the bottom of the run. At the top where it's really nice and hard, it was great ski for me to go, big radius turns, really nice carving turns, kept you on its edge, having lots of fun and you can take it through all the speeds, all the different speeds as well. At the same time I got in some really nice little short radius turns as well, really holds that edge really nice and grippy and you can ride it at speed or slowly as well. I had lots of fun on it and it's a really pretty ski and the ski I really enjoyed skiing this morning.


So, as you can see because of this zigzagging nature of the steepest descent method actually is the main reason for it to be slow and it will be slow when the condition number is large. So, what we can now think of is we need a method as I mentioned in the previous lecture we need a method that takes into account that does not simply follow the steepest descent, but rather takes into account also how this direction itself is going to change. So, it must take into account not only the gradient which tells you the direction of the decrease of the function, but also how the gradient itself is going to change which is and now that the way the gradient itself is changing is captured by the curvature of the function or in other words the Hessian of the function right. So, if we have a so the better method would be one that takes in that knows at this point itself that although this is the direction of steepest descent I should not actually be going here because this is not really a sustainable will not give me a sustainable decrease I would have to again change my direction and go in the in a in another direction etc. So, what we would need is ideally a method that kind of that is when while you are sitting here itself identifies looking at the curvature and all this other information identifies a better direction to move in and that is what is that is the that method is basically Newton's method. So, that is Newton's method. So, the step the it is again it is again a method like before, but now we are going to take the what we are going to do is take a Newton's step. So, P Newton at time k at iteration k is defined in this way it is defined as the Hessian of at xk is defined as the Hessian of x of the function at xk inverse gradient at xk. Now, the now here is one important thing to note see the Hessian itself may not be a it may not be positive definite. So, Hessian need not be positive definite and in that case the Newton the Newton's step or the Newton direction may not actually give you descent. So, the Newton direction may not be a descent direction may not be a descent direction if this is not positive definite. So, as a consequence a lot of what we discussed so far does not actually directly hold for the Newton's method meaning that we are we are not necessarily decreasing at every step with the Newton's method we are we are we are we may not even be getting descent we may in fact be getting ascent you may be increasing the objective value. So, so, so the the the the so when when applying Newton's method we have to be careful that we are actually we have although the the method is intelligent in the sense that it makes takes into account the curvature of the function you have to make we have to make sure that the that the that we are in fact getting descent right. So, okay, so let us so let us now discuss the rate of convergence of this sort of of the Newton method. Now, one other thing I want you to note here is in the Newton method is that the Newton step is itself has it has baked in it already the step size the step size has been chose has already found has already been found for you by taking taking into account the curvature of the function through the Hessian. So, it one does not usually need in addition to this another step size because the Newton step is is is a complete step meaning that it is not just a direction it is a complete it is a it is a complete step to a to the new to the next iteration right. So, here is the theorem so suppose f is twice continuously differentiable and the Hessian at x is Lipschitz continuous in a neighborhood of x star at which the sufficient conditions of optimality are satisfied. Now, what does this mean sufficient conditions of optimality are satisfied it means that it is a point at which gradient is equal to 0 and the Hessian is positive definite. So, that means the sufficient conditions of optimality are satisfied and consider the iteration. So, we write this for you in the bracket. So, the gradient at x star is equal to 0 and the Hessian at x star is positive definite right. Consider the iteration x k plus 1 equals x k plus p n k where p n k is as defined above. Then if the starting point x 0 is sufficiently close to x star then x k converges to x star the iterates converge to x star. Moreover, x k converges to x star quadratically that means if you look at the error between x k and x star that error decreases to 0 quadratically. Third, if you look at the norm of the gradients this norm of the gradients this also converges to 0 quadratically. So, let us take a note of a few things. So, I mentioned to you look at let us see what the theorem is saying that if f is continuously differentiable and the Hessian is Lipschitz continuous in the neighborhood of x star at which the sufficient conditions of optimality are satisfied.  Now, here is the main thing if x 0 is sufficiently close to x star then you are guaranteed that this will converge to x star.  See if the function may very well do other things elsewhere but around x you are close enough to x star. So, at x star the function has gradient equal to 0 and Hessian positive definite. So, in that in a neighborhood around x star the function is actually convex and what this is saying is that you are starting your iteration in that sort of neighborhood you are starting your iteration in a region where the function is convex. If the function is convex then in that case if you look at the Newton direction the Newton direction in that case that if the Hessian then if the function is convex then the Hessian actually is positive definite. If the Hessian is positive definite this is actually a then a descent direction and then so if you start your iterations in this sort of region then the Newton direction is a descent gives you a descent direction. So, what does this theorem say that if you start your iteration somewhere close enough then the iterates converge to x star moreover they converge quadratically and even your gradient vanishes quadratically the norm of the gradients also vanish quadratically. So, if you start your iteration somewhere in this sort of region then the Newton method not only converges it converges quadratically it converges faster than the steepest descent method. So, the main thing here is that because Newton direction is not guaranteed to be a direction of descent we have to include this rider that you are you are starting in this kind of basin of attraction where the where the function is actually in a neighborhood of the of the true minimum where you are the function is convex. Now, if the function actually is convex everywhere then things become easier and then this sufficiently close really is has no has no bearing on the final on the final result. But the main thing to note here is how we have got now quadratic convergence as opposed to linear convergence which is what which is what steepest descent was giving us. Now, now, so we can we can also do other variants of the Newton method. So, we can do for example, one can do instead of taking. So, in situations where the Hessian is not positive definite one can do one can come up with variants that often of the Newton method that that tend to mimic the behavior of the Newton method. So, for example, you could do simply pk equals some minus bk inverse gradient of f at xk where bk is symmetric and positive definite. So, bk is symmetric and positive definite. So, this kind of iterate is what is called a quasi Newton method. What this tends to do is it brings you a little bit of information about the curvature alongside and also gives you the properties of guaranteed descent. Now, the way the bk is obtained is through the past derivatives and past information that you have obtained about the function. And so there are there are many different ways of updating this bk one of the one of the one of the sort of most popular updates is what is called the BFGS update. So, we do not have the time to go into all details along all this the BFGS up gives you a method update it gives you a way of updating method for it is a method for updating updating bk. Now, what sort of what sort of result can we get for this kind of a all right. So, now with this I think there is this gives us this gives us a wide gamut of methods for solving unconstrained optimization problems. So, from here now we will move on to constrained optimizations.


202 SNAP participants and 368 non-participants were assessed to determine their opinions on proposed SNAP policies, revealing that the majority supported increasing federal spending, broadening usage of benefits, and improving food healthiness, while 60% opposed the America's Harvest Box proposal. This article was authored by Cindy W. Leung and Julia A. Wilson. 202 SNAP participants and 368 non-participants were assessed to determine their opinions on proposed SNAP policies, revealing that the majority supported increasing federal spending, broadening usage of benefits, and improving food healthiness, while 60% opposed the America's Harvest Box proposal. 202 SNAP participants and 368 non-participants were assessed to determine their opinions on proposed SNAP policies, revealing that the majority opposed the America's Harvest Box proposal.


Hello, welcome to SSUnitech. So, sale this site and this is continuation of sequence over interview questions and answers. So, today we gonna discuss about one more interview question that is how to write a query to get those employees who has salary greater than their manager. Have a look of table in next slide. So, as we can see we have input table that contains four columns. First is employee ID, then employee name, employee salary and manager ID. So, we are having total four columns and in our output we are also having four columns those are present in our input. But as we can see for Naveen, so his manager is Mukesh and Naveen's salary is 1 lakh and Mukesh's salary is 30,000. So, 1 lakh is greater than 30,000. So, Naveen will move to our output. Next for employee ID 5, employee is Joanne and Joanne's salary is 1,70,000 and her manager is Howard. So, Howard's salary is 1 lakh, 68,000. So, Joanne's salary is more than Howard. So, Joanne's record will move to our output. How we can write the query to get this output? Go to on SQL Server Management Studio and here as we can see I have already written this script to create the table and insert a record on it. So, we can execute this as we can see six rows affected. Now, we can check the data. We can write select statement, select a stick from our table. Now, we can execute and we can check. So, this metadata and our slides metadata both are same. Now, we can copy this record and go to on Excel to understand about the logic, how we can implement the logic. So, we are going to use self-drain. So, let me paste this result set two times and let's call it as employee and second as manager. First, we want to match with ID from employee table and then from manager table with major ID. So, this is our first join condition. In our second join condition, we will check salary for the employee and salary for the manager. If employee's salary is more than manager's salary, then we will put into our output. So, as we can see in our first room employee ID is 1 and manager is 2. So, it will match with our second record and here as we can see employee's salary is 1 lakh and manager's salary is 30000. So, first record will move to our output. So, it will be our output. In case of join, as we can see her manager's ID is 6. So, that is our Harvard. So, it will match with Harvard and here it will check for employee's salary that is 1 lakh 70,000 and manager's salary is 1 lakh 68,000. So, this record will move to our output. So, go to on sequence of management studio. So, go to on sequence of management studio to write the query. As I am using SQL 2K17, you may have another version of SQL server, but query would be same for all the versions. So, here this is our employee table as we have discussed. Then we need to put an inner join. So, this is our inner join and then this is for manager. In our on condition, first we need to check for the employee's manager ID. So, manager ID then it should match with manager's.id. That is fine. Next condition would be employee's salary. So, employee's salary that is our EMP cell should be greater than manager's salary. So, m dot EMP salary. We want to get data from employee table only. So, we can put employee dot star now. So, let me execute this query. So, as we can see we are getting ID1 and ID5. In our slide as we can see employee ID5 and employee ID1 we are having. So, I hope you have understand how we can write the query to get those employees who has greater salary than their managers. And thank you so much for watching this video. If you need this script it will be a label or description of this video you can copy from there. Thank you so much for watching and do subscribe our channel and press the bell icon to get the notification of our newly uploaded videos. Thank you so much.


So last year I created this presentation for this conference, and I actually did it, excuse me, did the talk about four times, and actually I got lots of flak, I got lots of love, so I decided to start 2009 off and do it again.  This year I don't want to talk about testing, I want to teach testing to you guys. So everybody here, who works in corporate America?  And our objective is, if my, oh I got to turn my mouse on, alright, and my objective is, is to get, there we go. I want to teach you guys one new thing, and I don't care what you get out of this, but I promise you by the end of this talk, in the next 40 minutes or so, that you will learn one new thing out of this. So, let's get on to the talk. So today we're going to talk about, no, we're going to listen to this great song first, that's what we're going to do. The song this is. Nah, nah, I'm kidding.  You know, because people have asked me this, and I had to come to conclusion, and it is, it's Taft. So, first of all, let's talk about this. Let's talk about this. Taft is a phenomenon, not a literal thing. Now what do I mean by this? People always come to me and say, Brian, are you testing right now? I'm like, no, I'm talking to you. And they'll come up and say, Brian, are you testing right now to test this code? Someone, I have people who go into my GitHub account, look through all my projects and see if there's enough tests.  Don't do that. It is a literal thing. We're talking about testing when you're supposed to be testing and testing things that are supposed to be tested, not everything. You know, I'm taking a step over here. I don't need to test that. I'm just going to do it. That's silly. So, for all those people, I want to send a PSA out. And you guys know what a PSA is, public service announcement. And the first one I want to send out to is, with this video, I love videos. Have you guys seen this video? Has Rails jumped a shark? Classic TV show right here. Other things that have jumped a shark this year.  I guess we can call it CAFT.  You know what? Take it that way. I want nothing to do with you guys anymore. And here's another one. And a lot of people in this room might be familiar with this people. And actually, let me say this one really slowly.  You know what? I jumped a shark. And you know something? There's this website out there called Rails WTF. That jumped a shark. They really do estog me. All my blog posts, all my Twitter posts end up on this site for some reason. These guys really do love me. So to you guys, I'm up here and you guys aren't. So whatever. I'm complaining. Let's talk about theory. And that's my littlest one. That's Abigail. She's going to help me do this thing today. And the first thing we're going to talk about is our testing toolbox. Because a lot of people ask, well, how do I test? It's not about how you test all the time. Sometimes you just need, you need some tools. And I'm going to go over seven tools actually to help you test. And let's start off. First you need some magnets and some rubber bands.  And this might sound kind of silly, but to start somewhere, you have to start at the beginning. And first thing you're going to need is something to test with. The second thing you're going to need is something to think everything else out. Just think about this for a second. You're going to get what I'm talking about. The next thing you're going to need is something to keep metrics. Testing is more about you can test, but you also need to have some kind of standard to compare your previous tests to. So I like to keep metrics all the time. And I'm not creating an acronym for that. And something to keep me grounded with reality. I'll explain this one. And another thing is something to keep me testing. And another thing is also, I am really sad this is not working, but something to create testable data. And Jim Wyrick talked about this yesterday and his fixtures and that long C word, but I can't say, so I'm not going to say it. And also something to keep me automated. I'm a huge automation fan. I really am ex-unix, ex-security, ex-lazy person. So I'm always looking for ways to automate everything I do. So let's go over these seven items. First, we want to talk about something to talk with. So the first thing I want to do is on the flashback of 2008 when we were at the Holiday Inn down in Orlando. And what I did is we're flashing back. I put up this slide and the first thing I said is, Brian L should like RSpec. And you know what? I did like RSpec until I met Shuda. And I also do this slide and I called this my magic testing combo. To tell you the truth, it doesn't look much like this because I use Shuda and RSpec. I still use test unit and RSpec story runner has been replaced by something else. We'll talk about later. But after using a lot of projects, there's a big split. And I realize that, you know what? It doesn't matter which one you're using. They're both robust enough that you can use either one. Just pick this one you like. So they're kind of even. I can't really say one is better than the other because either one has faults that make it, it makes it a moot point. So use what you like. And you know what? I mean, evangelize it. I like to hear the competitions, but use something. One of the losers here are the people who aren't testing, who don't know this one or this one. So let's get into our testing ones, the least ones I use. I use RSpec. And I like RSpec because RSpec reads in a nice English way. So I could say, if I have an apple, my apple should taste good. But Shuda gives us these things called macros. And we would write these a little bit different. And it should have speak. This would be like apple should taste good. And of course there's good old test unit, which we all love. Hey, Nathaniel. So we're going to all school assertions. I don't want to read this to you guys. You guys can. And then there's something new. Jeremy McEnally from ENCP down in Huntsville comes up with Context with Matchy. And the reason I didn't put a demo slide there because it can look just like RSpec. Or it can look just like Shuda. It's a good idea. This guy needs to keep on hacking because I think he brings out good ideas from everybody. So look at this GitHub slash Jeremy McEnally. He has a couple cool projects there. So the next thing I said we needed is something to fake everything else out. And you guys have any idea what I'm talking about here? Anybody? There you go, Anthony. So yeah. And the first one, and this is the one I use the most. I use Mocha. And the only reason I use Mocha is because it's what I'm used to using. I have no good reason to use it. But you know, it's what I've been using and it's what I make my developers use. So I try to stay consistent. And this is just an example of stubbing and mocking with Mocha. And the next example I'm going to show you is FlexMock. And the cool thing is that the FlexMock author is here. And I hope that my slide is correct, Jim. Because if it's not, just chalk it up as it's awesome to put on the board. Okay, thank you. But here's something else I've come up with. And I've heard people talk about this lately. And actually ENTP posted an article yesterday on their blog about RR, which is this double thing, which is actually kind of cool. I'm going to look at it. And I advise everybody here to take a good look at this. The method they're doing is actually making it a little bit more obvious when you have a stub and when you have a mock. So I can just have my stub and just say return this block. So taste, return whatever is in this block, which is good. Or my color, turn red. I love this. I will be using this in a project very soon. So you'll probably hear about this on my blog. And then we have the good old standby RSpec mocks and stubs. Nothing to talk about here. I'm sure everybody has seen this. So the next thing I'll talk about is metrics. And who here keeps metrics with their code?  The first thing I do is Ryan Davis, good old Zen Spider, create something called Flock.  He flogs his code and tries to do pain to his code. And what it does is it gives you this number and I'm actually going to show you a run of it. And on my blog earlier this year, actually last year, I came up with this chart of Flock output numbers. So what we have here is 0 to 10. If your method ranks 0 to 10, you're writing good code. And I don't even write code like this. I'm not really that good of a coder anyways, but I don't write code like this. Nobody in my team writes code like this. If you can do this, it's awesome. Most of us fit right here. We're not bad. We're doing, we're writing OK code. What this does, it measures method length, branching, conditionals, and assignments. So just make sure that your code is easy to read. It's actually a pretty good indicator of how easy to read your code is.  You know, they might write some code, might need some TLC. And then we have this write it over. And then the next one we have is where you should never be. And you'll see this right here. If you're running FLOG and you see this in your code, think of me.  Don't do that. So I can't go without having a demo. And I don't do live demos. So I hired a team of midgets that are behind the board and they're doing it for me. And notice I'm NVM, no text mate. And I'm NVM. And I just ran the FLOG on that code that you saw. And notice that those are my FLOG scores, the 21 and the 17. Notice that I'm not too bad, no low numbers there. But if you run this all the time and actually just run it again, if you run this all the time in your code, what it will force you to do is first write smaller, easier to read methods, not use so many branches, and, you know, keep your code in check. And actually there's a tool that I'll talk about later that, and this is where I got most of the stuff from, there's also Securo. Does anybody use this? This is kind of weird. This is kind of out there. And I can't explain to you what psychomatic complexity is, but I know that once I run this on my code, it becomes less psychomatically complex. And it's all about metrics. Who cares what your metric is? I'm less than I was before. Go read this site. I can't explain this to you guys. I had to go look up psychomatic in the dictionary and I still can't tell you what it means. The next tool is Rik. And that's my daughter helping us explain what Rik is because they didn't have a good picture on her website. Rik helps you find code smells. And, you know, I'm usually good at finding this in my code reviews from my developers.  Do it over. But this is actually something that we can measure. And once again, I have my midgets, and I mean my short people behind the board running my Vems. And what it does, this is kind of cool, it actually runs on your code and it gives you pointers of what you can do to fix your code. And you might not do it or you might do it. I love things that tell me how to do my job a little bit better. And you say, well, how does this help you test? What you do is you read green refactor. I think it's part of your refactor. You should be doing things like this. So if you need some help with that refactor phase, here you go. This will help. So the next tool is good old R-Cup. Mauricio, I don't know his last name, Fernandez, eigenclass.com, created this tool R-Cup. If anybody looked at the code of R-Cup and actually tried to figure out how to make it better, the guy's a smart guy. Or he's completely insane on one of those because he has some really hard to read code. Or maybe it's just because it's so crazy what it does. But what R-Cup does, as we know, is it tells us when we run a test of what code has been run or what has not been run. And it's only using C2 code coverage so it actually can't look in your, if you have an if with a boolean in it, it can't look at both sides. It doesn't want to look at one side. It only cares about what lines have run. But you should have this. As a matter of fact, before you're checking your code, you should always make sure that, hey, my code coverage going up or my code coverage going down. Right? Wow. I'm going to, I'm going to, I know you are Lark. I'm going to come back here next year and I'm going to ask that question again. That's really, at the minimum, this is so easy to run in your code. All you do is type R-Cup with your directory or your file name and it spits out something close to this. So another tool that I found is called Rudy. And this is an interesting one. Rudy is more about object-oriented design. I guess that's why it's called R-O-O-D. I don't know what the I stands for. And that's my daughter again. What she's doing, she's peering in my code looking for the bad stuff. Am I doing good OO? And actually I have a demo of this too. So I'm back in my VIM and my little people, that's what they're really called, little people. And this actually goes back pretty quickly and what it does is kind of like, reek, it just tells you things that you should be doing through your code. And that's what it does without elf clauses. Yehuda had that this morning and I wanted to call him on it. You've got to have an else clause in your case statements. So I didn't know that until I was putting this code. So next thing I want you guys to do, I want to have like a little call and response here and I'm going to say this and I want you guys to say it back because I think this is so important to measure and analyze my code is to know my code. That was awesome. That's exactly what I'm talking about right now. So the next, let's move on. So now we're talking about keeping ourselves grounded with reality. Anybody have any idea what I'm talking about? Any guesses about what I'm going to say right now? All right, I'll give you a little hint. Grounded with reality, grounded with business, the people who pay our bills, the acceptance of our code. And in the Ruby land, there's only I guess really one major player that's actually approachable when it's Cucumber. And what this is, this is Aslak Halasoi from the RSpec team put together this great piece of software. I guess it was a clean implementation of the RSpec story runner using TreeTop as the parser. And we use this. I try to get my guys to use it all the time. This is great. And a lot of projects are actually moving towards this. So what do we have here? What Cucumber gives us is plain English high level acceptance test of our code. Everybody in this room, including my wife who's back there, can read this. And they can actually see what this acceptance test does or what it should do. And the cool thing about this is that not only do your developers have insight to your code, your business side methodology you're using to develop, that person has insight to your code. They can actually help you write this kind of stuff. And you're saying, was this testing? Yeah, it's testing. It's acceptance level testing. It's actually very important. So go on again. I got to show a demo. So inside of the inside of I do have a demo here. It's taking a little while to get on there. So I have a Rails project called Downloader that we're releasing and it actually just lets you download files from the Internet. But we have features for it. And notice that I know it went by pretty quickly, but what we have here is that was behind the scenes. Ignore that guy. What we have here are plain text descriptions of what my code should do. And you say, well, how is this different than my low level test? Business wants your low level, your functional, your functional, maybe some of your integration test and your unit test describe what your code what you think your code does. And what they should do is they really should meet the medal. And I actually explain it like this to people. So moving on, now what we need is something to keep us testing. And who here is using continuous integration all the time? I mean this is part of your workflow. I know hashrock guys, you guys. It's like your way of life. At first, everybody, and I actually was on this bandwagon for a long time, was cruisecontrol.rb came from ThoughtWorks and it's an awesome piece of free code. Only problem with it is it's hard to use. It can be configured because it gives you all the source, but it really gives you a lot more than what you really want. So these days I'm actually telling some people to use this next project called integrity. And the difference between cruisecontrol.rb and integrity is first that cruisecontrol is a Rails app, integrity is a Sinatra app, is that the approach to testing is much simpler. All integrity once and I don't have a screen to show you this is, all integrity once is what do you want me to run? And it only works so it makes a lot of assumptions there and it has all these notifiers that you can use it. We're using with the campfire notifier that Chris Wonstraf wrote and I made work a little better. So if you guys are going to try this and you want a free option, integrity is easy to use. Don't use it on like Red Hat Enterprise 5 or CentOS, it won't work out the box. Do it like on Ubuntu and it works very well. And if anybody has any questions about it email me, come by me I'll help you with this. And if you're in the JRuby land I think this is called Celerity it's a very good tool for testing your JRuby apps and one thing that the Celerity can do is it can also do, it can do end testing, actually test your JavaScript and which is a big deal because most of our projects in here we have all these code and we have all RubyCodes tested but we don't have the actual user click tier and this part works. If you have a JRuby app you can actually have Celerity run it and it will do the form testing but some enterprising individual on GitHub has figured out a way to make this run with your MRI apps. So everybody else's apps. I have not, I have tried to run this there's a couple of issues, he could use a few patches, it only runs on port 80 right now and some other things but this right here is the feature this is definitely, I think if he if he doesn't make big noise about it I will be making big noise about this very soon and that's why I put the link up here just remember I guess the Langlex part so Jim talked about this yesterday fixtures, fixtures, fixtures something to create testable data I guess this pattern is called the object mother pattern some people refer to it as the object mother pattern only one thing to say is don't use fixtures don't use fixtures just don't use fixtures I can find one really acceptable test case for using fixtures and this is what it is if you are testing uploads in your application use a fixture for that put it in your fixtures folder in your Rails app, go test fixtures files and then put your file in there but for everything else there's other things we can use and let's talk about this first one is factory girl factory girl is written by Thoughtbot these guys have pushed out a lot of cool code Shada this, they have something called clearance they have a couple other projects that are really interesting and one thing I like about factory girl is that it's really unobtrusive to everything and I promise I would show some code and what this does is it doesn't invade your objects it actually uses the factory pattern to create your code here or to create your objects and actually this is for something I'm writing so this makes no sense to you guys I haven't released it yet I'm not constantly releasing and actually there's another project that I was informed of called machinist and machinist is something similar but machinist is really intrusive that it includes itself into your classes and then generates and it can generate fake data for you using it, sham, sim, blah blah blah blah blah I like machinist but I like factory girl so I have a problem now so what am I going to do? I've actually approached both of these teams and I said, well, why don't you guys merge products and you know what, we can make a franchise product and I said, you know what this is how I'm going to help I'm going to help you guys name your new product so I've been tossing around some ideas I have machinist it's both of them, it's the spirit of both of them and then there's another one a factory girl that rolls off the tongue then I was like, you know what, we are we're in the Y generation or the speed generation now we don't use big words I can do better they're not expecting that from me I'm just going to name it this cuff so this is where I am right now maybe there will be a cuff one of these days maybe there won't but either way, machinist and factory girl are very very good for generating data and actually I don't have a slide for this because I want to keep this quick but the radiant project actually has something else coming out or I don't know it's called data sets and this is a very cool idea I didn't put a slide up for it but if you go to github slash aiwilliams slash data sets they have a very good solution for generating a large amount of data like if you're testing radiant pages in your CMS actually probably in the next version of the screencast the next version of this talk I will have a slide in there for that because they definitely deserve their props and you know there's also scenarios which I do like but I've moved on to these two so there are options, just don't use fixtures because fixtures cause problems and jem's talk yesterday explained that in great detail the problems with fixtures so next we need something to keep us automated and we always need to remain automated it's very important because if you have to run your tests all the time by yourself you're probably not going to run them as often as you should be so what do we use we use auto test and you know it comes in zen test and this is another Ryan Davis tool I kind of wish he would just pull auto test out and use that instead of having to download and install the whole entire other zen test who else uses any of the other parts in zen test who else knows what the other parts of zen test are because auto test is like 5 files and there's a whole bunch of other stuff in there don't look at it but so on my friends are back and they're going to show us about auto test so to give you a little history here I work for a company called sourcefire we have an open source product called snort and we have a whole bunch of open source rules that we use for you know for bad sub detection on the network so we're basically creating an API so people can query this from the internet and of course it needs to be tested so this is how I do it I actually go in there and I just run auto test and it runs so whenever I change my code whenever I change my code it always runs my test for me I don't have to worry about what tests I need to run because guess what it's always running a test it knows a file I changed and it knows what tests have not passed so it only runs those because look how many tests are in here it only takes a couple seconds because I believe in fast test but still and I ignore those deprecations that's bad developer, bad developer, bad developer but um but notice we do, we're very good we actually try to stay below like um I say like a 15 seconds from a full run for my quick test set if anything put about that nobody's going to run it and I've been in situations where I actually was the guy at the back row where um I don't know how long that test we took the run because I don't think it ever did run while we were there so we don't want to be in that situation it's the whole broken windows thing keep them quick, keep them fast, keep them green and you'll always run them so moving on this is what we're here about and that right there where my seven my seven tools for allowing you to test all the fucking time and that is the foundation of what I think you need to even get started with testing so now that we have some tools for our toolbox um now we need more theory so now we have we have little Abigail we have our big sister Jaila and they're going to help us with this part so now we need some strategies and the first strategy I'm going to talk about is um spiking and throwing it away say if I hear spike and throw it away or if you guys are really a fan of throwing it away my developers have a problem with this and guys who work for me I'll say I don't want to solve this problem why don't we just sit down and we'll hack out code for half an hour and when we're done we'll understand the problem and then we'll throw it away we'll delete it and they'll say to me well it's not a waste, I said well no it's not a waste what I learned from there is the solution and now I can go back and write tests with my solution and then implement my solution I don't want to have that bad code in my system because it hasn't been tested it's like that spike all it allowed me to do was get my thought pattern right and that's all it was doing so I'm serious throw your code away seriously and I know there's a lot of I think there's a lot of believers in here but a lot of people watching this video where's the camera which camera is this camera these guys these guys I'm serious so keep it keep it short 30 minutes if you're spiking longer than 30 minutes for coding you're in a code session kill that and this is another slide I don't have a slide for this but I only code in 50 minute sprints I don't know how people can code all day long I code for 50 minutes I get up I go to the bathroom I get a drink for like 10 so I figure and I do this all day long I don't understand how people can sit down for 10 hours straight but I think you will be so much more productive as a coder if you get up once an hour and move around it's good for all of us all right back to our talk so now we have this another second point and this is something that somebody called me out on and I'm going to defend it right here right now today stop what you're doing look at your code and write tests if you don't have enough tests for what you've written go back and write them and then you'll want you to delete those tests are you telling people to delete your tests? yeah I'm telling you to delete your tests and you know why I'm telling you to delete your tests? do you know why? because I'll tell you why people can search for me on github I can search for a lot of people on github and what I see in a lot of products or a lot of projects are really bad tests a lot of assertions of 5 equals 6 or a lot of things that would happen anyways like low level tests where we're testing assertions or testing branches or second conditionals we don't test for that we never test for that what we always should be testing for is the behavior of our code don't test about what it does test about how it should perform and not perform for performance reasons but how it should act so test the behavior so that's what I was saying there and you know what Greg Paul had caught me and I didn't get to preface it with what I was really saying there because you know I was in the moment that's what I'm saying now I want you to go back and look at your test and if they're bad tests delete them you know why it's only code write it again because I bet when you write them this time it'll be a lot better than it was last time and I also like the little octo-kitty thing I just want to have a slide of that github guys has been great for our community we should give them a round of applause basically we're testing all the time sometimes we delete our code we're testing test driven development who here is a heavy TDDer BDDer about TDD with auto-test something a little bit different something that I didn't learn in school so I want to talk about it right now this is a method and this might not be the best method but a method for actually TDDing with auto-test it seems like it should be like plainly obvious to most people but some people still have issues with this so I want to talk about it it's red, make it test pass, it's green and then your refactor actually for the green it's right the least amount of code to make it pass and now that's cool but I want to talk about it you guys saw this movie didn't you alright so I'm going to talk about the message I don't have a name for this method but I'm going to call it the message so let's say we have some code here let's say we want to implement an object called a square and we want to test for the area should be a length of the side square so with the area so if you have one that's a square that the side length is 4 the area should be 16 am I right I don't have a degree so am I right alright think I'm right so I wrote this test and of course you have no implementation of this so when you write your test it's going to be like hey wrong among the arguments and I did cheat a little bit I actually did create the square class and that's all it's an empty square class and what I want to hear is it's called the message method and the first thing you need to do is you need to look at your message and that's the message and what you need to do is make that message go away so what is our method for doing this we either we have to change the message or we make it pass and that's what I tell people now change your message or make it pass so since you're using auto test whenever you change your code it's going to run anyways so how do we do this the first thing we're going to do is um we put our initial I'm sorry did I miss a slide there we go so we're changing the message here and what the message was before was we had a wrong number of arguments for initialize it's because we didn't have an initialize so now we have an initialize with sideline notice there's nothing inside of there it doesn't do anything but all I was doing was changing the message it says undefined method area for my square instance so and you notice and I'm pointing out the message for the people at home so they know what the message is and what I did now is I put in a method called area not supposed to do anything this message should not do any I mean the area method shouldn't do anything you really have to take these baby steps like this it's a very important part of the process so what do you do right here you change the message or you make it pass so now when we're in an area it's always going to turn nil because the method doesn't do anything so now what I'm going to do is I'm going to change the method and I'm going to make it pass so of course now I had to write a little bit more code here and this might not be the best implementation but it is an implementation because I hasn't been refactored yet but now I've made it pass and now I'm at great which is where we want to be but I was being and Yehuda you were right the real answer for this is I should have put 16 right here I'm up here on the stage and I didn't want to have like 15 iterations of this so what I'm just going to say this is slide 94 let's say I had like slide 94 sub 26 this is what it would look like I'm actually caring about your time so now we're back to all our test pass so what do we do when all our test pass is that going to run again I'm sorry so what do we take from this don't be afraid to throw a test I don't be afraid to throw a test actually Yehuda gave a great test at RubyConf about this and that was one of the lessons learned we want to move we want to move from less from more unit tests to less unit tests we don't really want the unit level I mean it helps us get to where we need to be but when we have these great APIs and we have tests at our API level who cares what the metal stuff does as long as our API is correct so don't be afraid to throw a test away and also because we just need to move on my daughter knows how to do it so we need to move on too and I just put this line in here because I thought it was cool once you start you can't stop and that's how I feel about the whole testing and getting into throwing things away and making everything right you can't be scared of just tearing it all out and saying screw it let's move on so now let's talk about a little bit more theory and this is not the testing part there's nothing to do with testing this is the hash tracker break pair program if you can you will write better tests if you have a buddy there with you writing tests with you I pretty much guarantee it you will write better tests if you don't cheat and what I did in my little slide back in slide 96 is I cheated don't cheat go through all the motions don't cheat your code don't cheat your test because all you're doing is cheating whenever you have to look at it next time or you're cheating next developer cheat the bottom line which means you're just fake so don't do that so now we're out of theory and I put this picture up here because someone put it on Facebook the other day and I just thought it was cool anybody know where I am in this picture? actually I was the funny looking kid on the bottom left and I think that's the reason I spend so much time playing these things like this keep me grounded keep yourself aware of it this is fun we're here on a weekend talking about Ruby code so now I want to talk about some more real stuff people ask me this what does your desktop look like I don't subscribe to the hash rocket 30 inch monitor thing and I don't get the program pair program a lot unfortunately because I'm like management real guy and usually just ends up over here somewhere so I actually just used this Mac I use this Mac for everything so 1440x900 is my resolution I figured out I use them I have a terminal and I have auto test and this is how it looks I actually almost have an Apple script it actually does all this for me I think this is very important and I use black I use light text on the black background I just think it's easier to see some people might not agree but if you notice right here I actually split and this is why I don't use TextMate anymore I want to be able to see my test code while I'm writing the implementation I think that is not too much to ask for I love TextMate and I actually did use it for some of these examples because copying as RTF is great for TextMate but when I'm actually trying to get work done them or Emacs I've been much better to me in the past weeks and actually if I read my blog I actually do this experiment and I'm going to finish it up with a post on why I'm sticking with them so let's look closer at my work area here so I use NerdTree NerdTree is awesome NerdTree them plugin and right here you'll see my test and you'll see my implementation down here ignore this very long method it actually didn't flow very well but you know what? we always need something to improve one but it does work because it's tested and then we have our test window which you guys have seen, we run on my test I don't run my features all the time because sometimes you just don't want to run your whole test week the whole time so most time I just turn I just have auto feature equals false so I don't have to run that one thing you need to realize is I think one of the pro tips here is that the faster you know that you failed is the faster you'll know your success so instant feedback is always the key and so now let's get into my talk my talk is like eight slides long that before was like the preface now let's talk about the talk so what do we need to do to be better at testing all the first thing we need to do is we need to write test first you can't get around that write your test first when DHH yesterday said that he doesn't write test all the time he was wrong because that app that he said he was going to be using is like there's a new status app and it needs to be tested write your test first I don't care if you're writing five lines figure out the appropriate amount of tests just say if you're writing a if you're writing a Sinatra application and it has one action just put a test in there that says that if I pass this in there a success if I pass in there it's a 404 big deal or it's a 500 but you need to have that test because you might have been in that right state of mind then but how do you how do you judge if features change somewhere else in your app or if you had something else on you might as well just start at the beginning write your test first only write code to make your test pass if you're putting code in your app and there's no test behind it or no high level functional or integration level test if you're writing a Sinatra application create a reason for yourself to write code and the way you do that is by writing a test submit code to continuous integration and that's my little continuous integration right here she's handling my code you know what's going to happen is you're going to write code and it's going to be awesome on your desktop and it's going to be super awesome on your desktop and it's not going to run in production if you submit it to a continuous integration on another server you at least have some guarantee that it's going to run somewhere else and it wasn't because of the esoteric settings that you have on your box number four is write more tests you're not writing enough tests right now so think about it, write some more after you write those tests write more code and number six is refactor constantly that's all what we do and a lot of people won't say this it's a craft, it's not for four to eight years or 12 years or forever like some of us and learn how to become programmers the people who are here the people who are like leading what we're doing they treat it like a craft, they don't treat it like it's one plus one equals two they sit down like an artist and maybe it isn't art but they sit down like an artist and they always should improve their craft so what we're going to do is refactor constantly like I did in these pictures we did for Christmas if you notice we did it until we gave up so what happens if you do if you follow my six rules you'll have profit, at least internal profit I can't speak for you you're making money so let's go on to my next part I talked about gathering metrics and those methods that I gave before, Rudy, Riek, Arkov and the other one are easily done for you by Metric Food Metric Food works with Food Project no matter what it is use this this is probably one of the most important things I can tell you to put in your app right now put that in there and another important thing I can tell you is read more source code everybody here should read like a novel go find a project actually I've learned a lot lately by reading Riek source code, believe it or not I've read it and I appreciate some things a little bit more because I think there's a lot of us to learn from just methods I've learned a lot from Yehuda posting his explorations into merging Mervin and what is that? Rails damn guys so read source code I think it's one of the best things we can do for ourselves and I wanted to set this up for questions and I know I'm like 40 minutes in so my next few slides are bonuses you can use OSX these might be relevant if not I'm sorry I can't help you one of my things that I want to tell people is don't use your mouse and this is nothing to do with testing I'm done with that talk don't use your mouse get the Google thing or get Quicksilver or get Launchbar I'm actually representing I'm actually saying Launchbar is a cost but Launchbar 5 is way better than Quicksilver ever was I'm not using getX I don't care if you're a get master I mean I can do a lot of the weird things from the command line but you will not have a better commit or a better view of your project if you're not using getX on the Mac and I think this is one of those projects like TextMate that make people who aren't on the Mac think about maybe I'll be more productive on the Mac I am all about them today because I had this couple months long and I've decided on them it's funny back in 94 when I got my first paid Unix job we used something called Vi and I always spent a whole bunch of time trying to get away from Vi and now I'm looking back where I am so so now and this is something that I don't think people use Vimperator if you guys are using Firefox and you like Vi now it actually allows you to do mouseless things with your editor just search for it it's actually pretty awesome and I don't have anything for it but it's pretty awesome so all I want to do is leave you with this all we can do is make our code work like it should and what it should is up to you really and the only way we can do this is by testing on fucking time so I have a couple things coming up and the first thing I do is I have TAF TV and I've been wanting to do this I've been wanting to do a screencast series where I talk about just random things no cost I actually do have some episodes planned where I will actually dive into more of the topics that I talked about today in a little bit more detail they won't be crazy like the Rails MB guys those guys, I don't have a green screen so I can't do all that but I promise you and so March next month we'll have test all the fucking time TV and I wanted to let you know that my wardrobe and travel were sponsored by my employer Sourcefire and they allowed me to get here today and I want to say thank you you guys have been great so now I know I glossed over a lot of things but I wanted to get a lot of things out there so I know there's questions and I want to know what happened in IRC what's up? you have to tap this dot com to resolve have you registered that? it does resolve, the MX resolves there's a story, I'm going to give a quick story last August I did a talk in DC about I did a talk in DC about testing and some shlub registered at tap.com and I had to go back and forth for a little while and I got the domain back and I was just so happy I had a set of email and I didn't put up a website so that's what happened with that there will be one there and it probably should forward to something else thank you for pointing that out in public alright anyone else? yes how do you keep your tests running as fast as possible? make sure this is more of a let me explain this to you I'll give you a little if you have read the pragmatic thinking in this book they talk about the triphus theory or method and there's like five stages or four stages that go from beginner to expert and what I'm trying to say here is there's the beginning answer and then there's the expert who knows and it's more like a sense of I just know what I should be doing I can't give you a definitive answer on that what I can say is stay out the file system never touch a network respect your object boundaries so if you're passing if you're testing object square and it needs something from object line mock that out who cares you don't care you just pass that in so yeah those are the three things I can tell you do you directly relate a vlog score to test me? no I don't think it goes down to that level you can't because flog only goes to your lines it wouldn't actually not know that and flog doesn't look at times either but that's interesting though anybody else? alright oh Mark can you compare contrast shoulda to r-spec and solvus from fighting about it all the time? yes I can I can start I can give you something on high level shoulda is a set of macros on top of test unit r-spec is its own thing that can actually run test unit um that's the easy answer the other answer is shoulda is um is macro-based and it introduces things like context and little should blocks r-spec the big I guess the big things for that are the syntax of your assertions I think r-spec really what it really wants to do is get you away from the old x-unit style assertions so instead of saying assert equals foo to thumb it would actually do foo should equal thumb so r-spec macros no reverse that shoulda macros r-spec matchers yeah that doesn't make any sense to me either yeah just recently now all of the shoulda macros can run in r-spec so I was mainly wondering how low level what kind of troubles you have oh okay I'll take my problems with r-spec and this is why last year I decided I would not use r-spec pretty much from day to day if you ever have to r-debug an r-spec you'll shoot yourself in the leg because you'll be like how did it even get there and where did this ad-exit come from when am I doing a test unit I thought I was with r-spec with test unit or anything built on top of that there's a pretty clean path through the code so you'll know before you died while you're there so if you happen to find a bug inside a test unit you'll find that bug pretty quickly and that was my problem with r-spec and also a test unit is a little bit faster in r-spec I mean I know it was a little while ago I don't know how it is now but on the high level day to day stuff they're okay they're even when it's fine yes I just want to say about spiking I find that sometimes I'm not talking about like hours but if you have to go to like half an hour it's useful at the beginning to write a new high level test so I know normally in spikes people don't write tests at all and it's actually useful to not but sometimes you're like okay I know basically what it has to do you can write some high level tests and then you can program and make sure you're not breaking stuff all the time or when you get to like okay time works now I think you've evolved to a level where you actually can realize what's wrong versus what's right and you have a sense of feeling well this feels right versus this feels wrong but a lot of people aren't even to that level yet where they can't say that they have no feeling their feet aren't even wet for testing they have no idea where they are and this is what I'm trying to do is get people close to your level where they can actually make that decision that you know what I'm going to write some tests now then I'm going to spike like that that's just going to be how I develop and actually that's pretty close to how I develop all the time I always start with I call them my little exploratory tests so high that they won't really do anything and they probably get deleted anyways but at least they get me started and the point that I really do use this for if you're ever developing a command line application testing a command line application I should write a blog post on this it's a hard thing to do because you're like oh that's he no it's not that's how I do that next question one of the things you said about the testing was you test the behavior of the application like with RSpec where it has given whatever and line then log and Lord had those exact kind of things in his talk yesterday we're talking about the acceptance test and knowing how far to go with the testing is always how much do I actually need to test right it's always kind of a controversial topic so past the acceptance criteria as defined by say a customer thinking you can get them to get as specific as you have there where they're testing the behavior like how far past that would you go with the testing since you were saying like you don't necessarily need to test conditionals and certain things like that well it goes back to that how comfortable are you it's a certain level at the beginner level maybe at the I don't know if it's the journeyman level the second level you might have to go a little bit further into your test being an experienced developer you might say well I already know what's going to happen here so I'm just going to I'm going to test this path through my code and then maybe test some exceptions and then stop there but at the beginning you might have to test the whole you might have actually started at the beginning say I want to be here and then ask yourself well why am I doing this and then ask yourself it's like that five times ask yourself why and then write a test for that and then continue doing that until you have something that actually works seems repetitive but that's how I think I started and now I think I have an affinity where I can actually don't have to ask myself why so many times because I think I started a lower level but I can actually just say I'm just going to write something here and that should come from here and I'm not perfect yet but I'm a lot closer than I was so my answer is um YMMV TATFT so if not I can say thanks you guys and it's been fun this is the first time I've done this talk so hopefully it didn't suck too bad and thanks


What happens when you combine the region's best network with a plan that requires no money down on the phone you choose, but also allows you to upgrade to the latest and greatest phone quicker than the traditional contract? You get the Appalachian Advantage, better service and bigger savings. Full payment plan requires historical details. Advantage requires no money down, taxes do a time of sale. March 13, 2018 will be a day the city of Pikeville will never forget. The day Scotty Hamilton, a 14-year veteran of the Pikeville Police Department, was murdered.  So, you're always trying to think positive and thinking the best, but you know the worst is probably waiting on you. It's with a heavy heart the city of Pikeville has announced that officer Scotty Hamilton was shot and killed tonight in the line of duty. For the next two days an intense manhunt was conducted for 55-year-old John Russell Hall. The man police believed was responsible. He was captured on March 15. The only thing I heard on the radio was, we've got him. You know, that's what come across our radio, and then we'll immediately send it out on a cad text to everybody letting them know he'd been captured. From that point on, Pike Commonwealth's attorney Rick Bartley kept the case at the top of his priority list, ending with a guilty plea and a sentence of life without parole for John Russell Hall on December 19th. That's amazing that within a seven-month period that, you know, the sentence is carried out and he's behind bars, and you know, it's soothing for the family, it's going to be soothing for his daughter later on down the road. His days are going to be spent in prison until they take him out of there. Also in the courtroom for the sentencing was Scotty Hamilton's widow, Chelsea. I'll probably never have closure, we're going to have to live with this rest of our life, but I'm glad to know that he is not out on the streets and that my husband did get justice. Today was hard, but I'm glad that it's over, and me and Brindley, my daughter can go on with our lives the best we can, and that's what Scotty would have wanted. And as the community pauses to remember what happened a year ago today, everyone who knew Scotty Hamilton says his presence is definitely felt. When he's looking above us, over there looking down on us, he knows we're doing our job, so I know that's what he wouldn't want. In Pikeville, I'm Shannon Deskins, EKB News.


Here's another Thrive Tip from Kaiser Permanente and Fox 12. You've probably heard since childhood that too much sugar can rot your teeth. These days dieticians say people are consuming more sugar than ever. The good news is proper oral care and small dietary changes can significantly lower your risk of tooth decay. People are consuming a lot of sugar these days. Bacteria live in all of our mouths and when we eat sugar or cook starch they eat the sugar in the cook starch and then they make acid as a by product and then the acid dissolves the tooth and causes the cavity. By choosing foods and drinks that you eat and drink wisely, you can maintain good oral health by limiting sugar, limiting acids, and brushing your teeth really thoroughly two times a day for two minutes each, as well as getting a piece of dental floss in between your teeth and by drinking a lot of water. Dentists say looking after your teeth is important if you want them to last a lifetime. This has been another Thrive Tip sponsored by Kaiser Permanente and Fox 12. Visit kptv.com slash thrive for more information.


but there's so many issues that I have with the filters. The first one is that they just go through water way too fast, I mean, I know that I'm somebody who drinks way, way too much water, but even drinking about a third of my water out of the machines at work, I mean, I'm lucky to get maybe 10 days out of a filter. I'll be lucky to get two weeks. Sometimes it'll taste really bad when you first put the filter in. Sometimes it'll start tasting really bad a weekend. It seems like these filters are hit or miss.


Welcome to a new video in the 23 part collection. This is 23 Michael Jordan videos in 23 days Today we have a story on Gerald Wilkins the apparent Jordan stopper and also Dominique Wilkins brother He tried to stop Michael Jordan and it went horribly wrong and this is the story of what happened If you're enjoying the 23 videos in 23 days Michael Jordan edition Can you please help me up by hitting that like button all the likes really go a long way to supporting the channel? be sure to hit that subscribe button if you are new and you enjoy MJ content just like this one and All the footage used in this video is on the screen right now. So be sure to check them out in their entirety I don't want to keep you guys waiting. So this is the time that Gerald Wilkins trash talk Michael Jordan and it went horribly wrong Cleveland was a great team. You had Mark. You had hot rod Williams Larry Nance You had Dordie who's arguably one of the better centers in the league at that time. They had a nice squad Obviously, I get asked about that a lot, you know bulls and I hate having to play the bulls every year And the thing was was I I love this We brought up your brother the other day when he was labeled the Jordan stopper Well, if it's May in Chicago It must mean that the bulls and calves are about set to go and yet another seven game playoff war All season long their whole main focus was to beat the bulls and playoffs because what we had meant to them in your past and You know the acquisition of Gerald Wilkins was both being kind of a final piece of the puzzle Cleveland in the offseason brought in Gerald Wilkins to be the Jordan stopper I felt bad for your brother because you knew that was gonna make Michael When you all you're the Jordan stopper, huh? You know has done a good job in the past, but they needed help so they went out and they got Gerald Wilkins to come in Go out and put the job on him to shut him out keep his numbers down You know what I called my brother when he said that and I said so I said, what are you doing? I said you don't want to wake up sleeping giant.  Jordan their offensive player As I say he has the ability to take over and he'll have spurts where he might score 15 points in a row for Chicago And this is one of those spurts Michael can and he'll take they'll take this off right on to the whole To follow Stacey King came in and played well off the bench for the right-hand side Lots of times guys trying to keep fresh legs on Michael Stopping Jordan is not a one-man job I want to prove to them that hey no matter what you do what changes you make I'm overcome that challenge Hey You know if you're a good defensive player you don't have to talk about it man Go inside Michael You don't want to get him riled up now. I think he ever like 40 in that series Yeah, whenever there was this guy's the next Jordan or this guy is the Jordan stopper I went this isn't gonna go well It's just it's not Three seconds Jordan There's no better environment than those hostile environments as an opponent You look for challenges you took to your Wilkins upon his word in the first Michael George stop ahead of time The series only drama would come in game for no tomorrow for the Cavaliers it's win or the season ended You take it to the hole with your left hand Very inspired basketball right now trying to accept the challenge and although Michael Jordan makes this jump shot No, we'll try to start taking things Responsibility that's a good good job right there. It's not allow Chicago to get back to his game You'll see him right here price gets around wanted to foul A moment of one into the fourth period I With time running down the Cavs would make one last stand to try to avoid a humiliating sweep Trailing by one with 18 seconds to go the Bulls sense that a familiar scene was unfolding I Was our go-to guy anytime in situations like that, you know, everybody in gym knows he's gonna get the ball He was the first option and the second option if possible My mind's off to think about all the other winning shots that I've made and Here we are in Cleveland again Same scenario in a sense. What's that stuff on the court? I had total confidence that I was gonna make the shot It's those superstar players except to the park that are able to put a team on its back or to hit that great shot That needs to be hit at the right time And as good as we were and I mean it wasn't like we were playing bad in those in those games and in those series I mean Chicago and Michael just were able to to always just take it up one more notch Five four Michael strip got it back three two Michael falls fire I've seen him do a lot of things but that what that one shot was just something incredible as a teammate As a player probably as a fan. It was a nice moment in you know in Bulls history Michael right over Wilkinson in his face and the Bulls have swept the Cleveland Cavaliers I got to give Joe Wilkinson credit, you know, he played a hell of a defensive play on me He made me take a tough shot, you know, I made the tough shot, you know, we won the last shot and fortunately it went down for him like time stop for a few minutes to let the ball just soar through the air and You know once it went in it was like Now we'll do the next round And I hope you guys enjoyed the video if you did Please help me out by hitting that like button all the likes go a long way to supporting the channel Be sure to hit that subscribe button if you did enjoy the video and here are two new Michael Jordan videos That I think that you should also check out if you enjoyed this one, too I will catch you guys in the next video tomorrow. Take care