QA Friday 2015-Dec-18

Take Up Code - Podcast autorstwa Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Kategorie:

What are logical operators? I sometimes find this question asked online and thought it would be good to explore in today’s episode. There are only three and you might think you already know how to understand them. But have you heard of short circuit evaluations? If you don’t fully understand how logical operations can sometimes exit early, then at best, you’re going to write some inefficient code. And most likely, you’re going to introduce some hard to find bugs. The AND operator is used to build up a series of terms or conditions that all have to be true in order for the entire series to be true. The OR operator is similar except that only a single term needs to be true in order for the entire series to be true. The NOT operator just switches a single term to the opposite value. The episode also describes short circuit behavior. This allows the AND operator to return early when it finds the first term that’s false. The OR operator can return early when it finds the first term that’s true. Listen to the full episode or read the full transcript below. Transcript Okay on to the question this week. Some bugs happen all the time without doing anything special in a program. The QA team just writes down a series of repro steps that result in the buggy behavior. Repro is just short for reproduce. A repro step is something you need to do in order to hit the bug. This type of bug is said to be 100% reproducible. Other bugs start out being documented like the simple case. Yet when a developer tries following the steps, the program works just fine. The bug ticket can sometimes go back and forth as the details are discovered. Once the exact steps are refined, the bug is again at 100% repro rate. Some bugs can never be fully defined like this and might be due to some timing issue that’s outside of direct control of the QA team or the developers. These bugs might have a repro rate of 10%, 20%, or whatever seems reasonable. Most of the time, the percentage is just a guess. If you don’t understand how logical operators work, then you’re more likely to introduce bugs that fall into the second category that take a bit more effort to pin down or sometimes even into the third category that can never be fully reproducible. So now that you know how important this topic is, what are the three logical operators? The first is “and”. The second is “or”. And the third is “not”. It can sometimes be a little hard to say them without getting them confused with the normal word and that comes before the last item in a list. These operators work by themselves or in combination to specify a true or false condition. You normally find them inside if conditions, while loops, or in return statements. Let’s look at what each one does by itself first. The and operator is used to build up a series of terms or conditions that all have to be true in order for the entire series to be true. You need at least two conditions to test for this operator to make any sense. Why at least two? Well imagine if I told you “In order to win the game, you need to score at least 50 and…” Now if I just ended my statement like that, it doesn’t make any sense. I need to finish maybe like this, “In order to win the game, you need to score at least 50 and your character must survive.” Now it makes sense. We could add a third term as well. Let’s say this is a rogue game and you also want to arrive at the end with a full backpack. If anything is missing or stolen, then you lose no matter what your score is. This new expression would then read like this, “In order to win the game, you must have a score of at least 50 and you must survive and you must have a full backpack.” We have three terms and they must all be true in order to win. But a single processor can only look at one of the terms at a time. So if the processor first tests the score an

Visit the podcast's native language site