Software with a Guarantee
|
|
- April Norman
- 5 years ago
- Views:
Transcription
1 1. Unit Testing Software with a Guarantee We ve settled in Objectville for quite some years now. Time for a new and nicer car. But we wouldn t dare buying one without taking it for a test-drive first. How do you know your software works? The only way to be absolutely sure is by playing around with it. Using it, and watching it to see if it behaves as required. Right? Wrong! We can isolate tiny units of functionality and test them thoroughly. And we really need to. Because only tested features can be delivered with a guarantee to function properly. Classic testing, if done altogether, isn t much fun. Covering all those different circumstances under which our software might be used is a lot of (that not much fun) work. We re supposed to be the software builders, not the users playing with it. Let s see if we can change the way we test software. Perhaps we can even make it fun. this is a new chapter 1
2 Unit Testing Monday Morning, 9:11 am Broke Bank, one of the most respected financial institutions in the country, has decided to finally go Java with their online banking software. Sharon, CEO at Tedious Software, Inc. gets a call Hi, Charles. What a nice surprise. How are things at Broke? If we what? would like to put in a contract for your big Java Project? You bet. You faxed the details already? All right, I ll get right on it. Talk to you soon! Bye. Fifteen minutes later, Sharon walks into our office asking us to write a bank account class in Javaa as a sample for Broke Bank. The contract depends on the quality of this one chance class. Oh, and as is usually the case, it s needed in a hurry. Deadline: noon, today! 2 Audition Chapter
3 No big deal (for a big deal) Let s get right to this. It s seems almost as easy as a school exercise (or one out of a book). We re pretty familiar with an object oriented approach, so let s follow the classic recipe for building this class. 1. First we have to decide on a name for the class. BankAccount seems like a nice one here. public class BankAccount 2. Next we wonder if BankAccount objects should keep any state. Well, they re sure as!heaven supposed to hold some money, so let s add a variable for this right now. //state private int balance; Remember, we hide state and let behavior drive state for two simple reasons: - abstraction (suppose we migrate to a BigDecimal balance later on) - controlled access (nobody should be able to set his bank account balance, right?) I know, we should provide for a fractional part. But Java hasn t a built in fixed point primitive data type like decimal in C#. So we would have to use the BigDecimal class, as we should never ever use a floating point type for currency.. But let s keep things simple here, for now. 3. Finally, we add some behavior to make the class useful. As specs are still coming in, we ll stick to some good old fashioned deposits and withdrawals. //behavior private void deposit(int amount) balance += amount; private void withdraw(int amount) balance -= amount; you are here 3
4 Unit Testing Testing time That couldn t have been more easy. Before we hand it over, let s play a little with it just to make sure it works fine. For that, we ll need a main-method. public static void main (String[] args) //First we try to make our first BankAccount BankAccount myaccount = new BankAccount(); //We deposit some money myaccount.deposit(25); //And we withdraw a little myaccount.withdraw(5); If everything goes as planned there should be $20 on myaccount. How can we check this? We need a method to return the account balance. Let s add that one right away private void getbalance() return balance; and finish our test //And we withdraw a little myaccount.withdraw(5); //Let s see if everything went fine System.out.println("My account balance, " + "starting with $0, " + "after depositing $25 " + "and withdrawing $5,\n" + "is now $" + myaccount.getbalance() + "."); 4 Audition Chapter
5 Like a charm. We rule big time. That contract is as good as ours. So let s get this shipped and go to lunch early. Perhaps we can celebrate with a nice bottle of wine. Shouldn t we count our chickens after they hatch? Sharon said quality was very important. Relaaax! We did test everything before we delivered it. Didn t we? May well be! But let s hope for the best. Because we sure didn t prepare for the worst. you are here 5
6 Unit Testing The next morning, 7:54 a.m. Sharon is waiting in our office as we come in. And she doesn t look happy. Here s your software back. There s some terrible bug in there causing negative account balances. Mike: How is that possible? Helena: I told you this was bound to happen! Mike: Well, no negative balances. That wasn t specified as a requirement. Sharon: I don t care how it happened. All I know is that I m looking stupid now to this new prospect. I called in some favors and we ve got a second chance. We can turn in a new version today, again by noon. So I suggest you get started! Mike: We re very sorry. We re on it! Trust us. Sharon: I wish I could. But this time I m going to test it myself before we ship it! Jason: Well perhaps we can prove that everything works fine by showing you our test code. Sharon: What do you mean? Jason: Well I read about this structured way of writing these tests called unit tests. Sharon: Whatever gets the job done. I ll be back in a few hours. And I want quality results. 6 Audition Chapter
7 5 minute standup meeting Mike: Jason: So, Jason, what about those unit tests. Well it s a paradigm shift in looking at testing software. Helena: Shouldn t we focus on solving the bug first? Jason: Peter: Mike: Perhaps. But we ll still need to test if it got fixed, no? I think I know what went wrong. It shouldn t be possible to withdraw more than the balanced amount of money in the account. Exactly! How could we have overlooked this? So all we have to do is write a control statement in the withdraw method. Let s do this. private void withdraw(int amount) if (amount <= balance) balance -= amount; Helena: Shouldn t we do the same with the deposit method? Peter: No. Since it s only adding money to the account. Helena: That means we re done? Mike: Jason: Mike: Jason: We just have to test it. So we have to add some more code to our main method. Not exactly. We need to get rid of that main method! What do you mean? We need to test this! That s where unit tests come in. [Suggestion: Mike could state the fact that messing around with that main method isn t the way to go, as it ll soon start to be one large blob method. Then Jason could reply that unit tests are the answer. ] you are here 7
8 Unit Testing Unit tests So here we are. The classic approach to testing, if there ever was one, has long been some programmer taking his software for a test-spin in some quick and dirty try-out through a main method or some equivalent. The programmer thus inspecting the output from the method when it s run. There are however some serious disadvantages to this approach. 1. Very soon, a main method gets cluttered with code that tests a lot of different things. 2. There s contamination. Typically every code that s written has to build upon the context of everything that s written before. It s basically one big blob method. 3. The sole alternative very often being commenting out some earlier test code or just deleting it before running the whole. 4. When that main method is run, the programmer manually (i.e. visually) has to inspect the output to see if she got what she expected. This is a very tedious and repetitive task, and people make mistakes when something has to be repeated over and over again. Also it s very time consuming and non productive. 5. Also, the main method very often gets distributed along with the software. 6. Hence, testing isn t much fun. It s often reduced to the bare minimum just because programmers want to be creative and produce new code instead of setting up some elaborate test code in a huge main method. 7. A lot of the assumptions made by programmers need to be documented (in the code or somewhere external to the code). The documentation and assumptions are often separated from the code that s making the assumption. Or documentation and assumptions are written in a totally different language altogether (we code in a programming language but document in a natural language or in a visual language like UML). 8. As such, computers can t read the assumptions we make, even if we document them. If they can t read them, they can t check them. When something has to be checked repetitively, how can we cope with that? Who s very good at making formal checks and repetitive tasks? Our computer is! Each programming language can check things (selection choices) and repeat things (iteration loops). So why not give the tedious and repetitive tasks to the computer? Giving tests to the computer takes them out of our hands. Making tests the computers responsibility also means programming them. Programming is a lot more fun than reading output from a screen. 8 Audition Chapter
9 Wait a minute! And exactly how are we going to tell a computer to read a screen? We don t have to do that. We can just provide the test-code with the expected output. So the test executes whatever functionality it wants to test and compares the expected output with the actual output. If they are different, the test fails and we have to alarm the programmer. Ok. And how about the other issues? Tests should be isolated, repeatable, automated, and so on. real output expected output You re right. There s a lot more to cover. But you know what? Let s just dive in, write our first test and then take it from there. no fail test! == yezz pass test! you are here 9
10 Unit Testing Your First Unit Test To cope with the separation of test code from production code, we ll create a whole new class that we will call BankAccountTester. Why? Because this class... <drumroll /> <crash /> is going to test our BankAccount class. Besides, classes should have clearly outlined responsibilities. public class BankAccountTester Each isolated test will get its own method. private static void testdeposit() BankAccount testaccount = new BankAccount(); testaccount.deposit(20); if (testaccount.getbalance()!= 20) System.out.println ("Oops!"); All test methods then get called from a main method. public static void main (String[] args) testdeposit(); 10 Audition Chapter
11 Q: Shouldn t we provide an else clause to the test? No. If all went fine, there s no reason to bother the programmer. In fact, suppose we have hundreds of tests all writing they passed. This would clutter the output in the console, possibly even hiding failed tests between the endlessly scrolling output. Nonetheless, with a graphical interface we could use controls like a tree view and gather statistics on all tests, failed or passed. That s exactly what we ll get when we start using a test framework. As a matter of fact, the oops message will be exchanged for some contextual description of what went wrong and where it did, what we got and what was expected. Be patient, grasshopper! Q: Why the long name for that test method? Shouldn t method names be short? Because it will only be called once and it should be very descriptive of what feature or unit of functionality we re actually testing. Descriptiveness in this case is of utmost importance. Again, when we ll start using a test framework, we won t even have to call it once. The framework will do it automatically for us. Q: I get it. And we write a test method for every method in our BankAccount class, right? No. Not at all! As we will see, a method can be tested for a lot of different use cases. For instance we could test what happens when we withdraw money when there s enough. But we could also test withdrawal of too much money for the account (more than its balance). And sometimes a test will call several methods of the class under test. So there s a many to many relationship between methods and tests. Q: Why do we call it a unit test? Because, if you reread the previous answer, a test isn t about testing some method. It s about testing a specific piece (a unit) of functionality. Q: Why is the test method static? Because it simply has to be if we want to call it from a static method like main, without creating any objects from this test class. This problem will also get solved automatically if we ll start to use a test framework. Q: Why doesn t the test method have any arguments? A test should be contained and isolated, and certainly not depend on the context of its caller. With parameters it surely would be. On top of that, in a framework, tests should be run automatically by a machine. A machine can t figure out any parameters. Q: What about documenting assumptions? Coming up next! you are here 11
12 Unit Testing Dissection of a Test Let s refactor our test a bit, making it document any assumptions, and dissecting it to find out each part of its structure. Let s get everything we need to set up private static void testdeposit() and prepare for the test //SETUP BankAccount testaccount = new BankAccount(); int initialbalance = testaccount.getbalance(); int someamount = 20; //EXECUTE testaccount.deposit(someamount); //TEST if (testaccount.getbalance()!= initialbalance+someamount) System.out.println ("Oops!"); This code clearly documents any assumptions we make to call this a successful test. Whatever the balance was, what we deposit should be added. Is what we get after running the functionality under test actually what we expected? If not, make clear the test failed! Go! When everything is set up, we call the functionality we want to test Now, could you write the unit test for withdrawing money under normal circumstances (having enough money in the account)? And what about a unit test to see if nothing gets withdrawn when we try to get more money out of the account then it has on its balance? 12 Audition Chapter
13 Wrapping this up (solution to sharpen your pencil) Here s the unit test that checks withdrawal under normal circumstances (that is, having enough money in the account): private static void testnormalwithdrawal() //setup BankAccount testaccount = new BankAccount(30); int initialbalance = testaccount.getbalance(); int theamount = 20; this assumes a constructor for this test to pass, so code evolves as tests are added! //execute testaccount.withdraw(theamount); //test if (testaccount.getbalance()!= initialbalance-theamount) System.out.println ("Oops!"); and the one making sure nothing happens when we try to take too much money out of the account (more than it has on its balace): private static void testwithdrawingtoomuchmoney() //setup int initialbalance = 10; BankAccount testaccount = new BankAccount(initialBalance); //int unchanged = testaccount.getbalance(); int toomuchmoney = 20; //execute testaccount.withdraw(toomuchmoney); //test if (testaccount.getbalance()!= initialbalance) System.out.println ("Oops!"); so this could have read unchanged as name for this member variable could help document the actual test even more Look how this documents things. It s almost readable natural language. if (testaccount.getbalance()!= unchanged) you are here 13
14 Unit Testing I m afraid I don t see any benefits here? We re actually writing MORE code. We don t even have the time to fix bugs and keep up with writing production code. Well, don t be afraid. In fact that s the first concern every programmer new to all this seems to have. It may very well be that we end up writing more code. And we may even introduce a bug into our tests. But the whole point of writing unit tests isn t so much that we test, because that was what every programmer used to do one way or the other. The big benefit from unit tests is that they actually do their own testing (instead of some poor programmer having to read output to see if all went right). Furthermore, unit tests are isolated from each other, not contaminating each other while running and they are automatically repeatable (as much as you like write once, run many). As we will explore test driven development and emerging design further on in this book, we ll learn that having lots of unit test that are very cheap to compile and run is of key importance. They not only prove functionality but also guard it! Finally, tests let us quantify both work and it s quality in software building. That s all very nice. But isn t this test code just about small, obvious pieces of code that seem just too easy to go wrong? And as many of those unit -things as you might write, they re never going to guarantee bug-free software, right? That s true. We don t have a complete guarantee. But we didn t have that before we started writing unit tests either. But we do have all of the advantages we mentioned above just by restructuring our test-drive code in our main and adding the actual control to the test. A very small step for the programmer but a huge leap forward in building flexible software in a test driven way. Software that will emerge as requirements are gathered and translated into new tests. This example might indeed seem too easy to go wrong. But what if we told you that the bug still isn t fixed? If you didn t realize this yet, perhaps you can see it, now we ve told you? No? Well then even this too easy example might not be as obvious as it seemed at first. 14 Audition Chapter
15 More to come in Head First Test Driven Development and Emerging Design Discover the benefits of collective code ownership Find out Do we really want to engineer software? Discover the secrets and patterns of refactoring! what triangulation has to do with building software? the difference between a Yeti and a Yagni about anticipatory design the color code of unit testing what s the fuzz about test coverage, code hygiene and cyclometric complexity What if you wrote tests first, grasshopper? Learn about mock objects, stubs and proxy s Be able to tell your friends all about JUnit and emerging design you are here 15
The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationSpam. Time: five years from now Place: England
Spam Time: five years from now Place: England Oh no! said Joe Turner. When I go on the computer, all I get is spam email that nobody wants. It s all from people who are trying to sell you things. Email
More informationCS125 : Introduction to Computer Science. Lecture Notes #11 Procedural Composition and Abstraction. c 2005, 2004 Jason Zych
CS125 : Introduction to Computer Science Lecture Notes #11 Procedural Composition and Abstraction c 2005, 2004 Jason Zych 1 Lecture 11 : Procedural Composition and Abstraction Solving a problem...with
More informationStoring Data in Objects
Storing Data in Objects Rob Miles Department of Computer Science 28d 08120 Programming 2 Objects and Items I have said for some time that you use objects to represent things in your problem Objects equate
More informationAnimations involving numbers
136 Chapter 8 Animations involving numbers 8.1 Model and view The examples of Chapter 6 all compute the next picture in the animation from the previous picture. This turns out to be a rather restrictive
More information3 Continuous Integration 3. Automated system finding bugs is better than people
This presentation is based upon a 3 day course I took from Jared Richardson. The examples and most of the tools presented are Java-centric, but there are equivalent tools for other languages or you can
More informationPRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO
PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE Speaking the Language of OO COURSE INFO Instructor : Alper Bilge TA : Gökhan Çıplak-Ahmet Alkılınç Time : Tuesdays 2-5pm Location
More informationYup, left blank on purpose. You can use it to draw whatever you want :-)
Yup, left blank on purpose. You can use it to draw whatever you want :-) Chapter 1 The task I have assigned myself is not an easy one; teach C.O.F.F.E.E. Not the beverage of course, but the scripting language
More informationChapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change
Chapter01.fm Page 1 Monday, August 23, 2004 1:52 PM Part I The Mechanics of Change The Mechanics of Change Chapter01.fm Page 2 Monday, August 23, 2004 1:52 PM Chapter01.fm Page 3 Monday, August 23, 2004
More informationCS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style
CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming
More information6.001 Notes: Section 15.1
6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define
More informationCS 161 Computer Security
Wagner Spring 2014 CS 161 Computer Security 1/27 Reasoning About Code Often functions make certain assumptions about their arguments, and it is the caller s responsibility to make sure those assumptions
More informationIAE Professional s (02)
IAE Professional Emails (02) TASK ONE: There are three different styles of writing when it comes to communication via email: Formal This is the style of an old-fashioned letter. Ideas are presented politely
More information1.7 Limit of a Function
1.7 Limit of a Function We will discuss the following in this section: 1. Limit Notation 2. Finding a it numerically 3. Right and Left Hand Limits 4. Infinite Limits Consider the following graph Notation:
More information4. Java Project Design, Input Methods
4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java
More informationFunctional Programming, Classes, and Recursion!
CS 1301 Homework 9 Functional Programming, Classes, and Recursion! Due: Monday, April 20 th before 11:55 pm THIS IS AN INDIVIDUAL ASSIGNMENT! Students are expected to abide by the Georgia Tech Honor Code.
More informationLecture 14: Exceptions 10:00 AM, Feb 26, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 Contents 1 Exceptions and How They Work 1 1.1 Update to the Banking Example.............................
More informationThese are notes for the third lecture; if statements and loops.
These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern
More informationIntroduction to Programming
CHAPTER 1 Introduction to Programming Begin at the beginning, and go on till you come to the end: then stop. This method of telling a story is as good today as it was when the King of Hearts prescribed
More informationTaskbar: Working with Several Windows at Once
Taskbar: Working with Several Windows at Once Your Best Friend at the Bottom of the Screen How to Make the Most of Your Taskbar The taskbar is the wide bar that stretches across the bottom of your screen,
More informationUnit Testing as Hypothesis Testing
Unit Testing as Hypothesis Testing Jonathan Clark September 19, 2012 5 minutes You should test your code. Why? To find bugs. Even for seasoned programmers, bugs are an inevitable reality. Today, we ll
More informationSPRITES Moving Two At the Same Using Game State
If you recall our collision detection lesson, you ll likely remember that you couldn t move both sprites at the same time unless you hit a movement key for each at exactly the same time. Why was that?
More information1: Introduction to Object (1)
1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:
More informationLOOPS. Repetition using the while statement
1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while
More informationThe first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.
Graphing in Excel featuring Excel 2007 1 A spreadsheet can be a powerful tool for analyzing and graphing data, but it works completely differently from the graphing calculator that you re used to. If you
More informationAPPENDIX B. Fortran Hints
APPENDIX B Fortran Hints This appix contains hints on how to find errors in your programs, and how to avoid some common Fortran errors in the first place. The basics on how to invoke the Fortran compiler
More informationModule 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 10A Lecture - 20 What is a function?
More informationAgenda: Notes on Chapter 3. Create a class with constructors and methods.
Bell Work 9/19/16: How would you call the default constructor for a class called BankAccount? Agenda: Notes on Chapter 3. Create a class with constructors and methods. Objectives: To become familiar with
More information5 R1 The one green in the same place so either of these could be green.
Page: 1 of 20 1 R1 Now. Maybe what we should do is write out the cases that work. We wrote out one of them really very clearly here. [R1 takes out some papers.] Right? You did the one here um where you
More informationDER GOBBLE. Good Secure Crypto Wallet Practices. What is your wallet?
DER GOBBLE Good Secure Crypto Wallet Practices When it comes to crypto currencies and securing your money, the absolute best 99% guaranteed security for your wallets is YOU. You are the one that will expose
More informationStage 11 Array Practice With. Zip Code Encoding
A Review of Strings You should now be proficient at using strings, but, as usual, there are a few more details you should know. First, remember these facts about strings: Array Practice With Strings are
More informationCOSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22
COSC 2P91 Bringing it all together... Week 4b Brock University Brock University (Week 4b) Bringing it all together... 1 / 22 A note on practicality and program design... Writing a single, monolithic source
More informationDivisibility Rules and Their Explanations
Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although
More informationAnnotation Hammer Venkat Subramaniam (Also published at
Annotation Hammer Venkat Subramaniam venkats@agiledeveloper.com (Also published at http://www.infoq.com) Abstract Annotations in Java 5 provide a very powerful metadata mechanism. Yet, like anything else,
More informationCOMP 161 Lecture Notes 16 Analyzing Search and Sort
COMP 161 Lecture Notes 16 Analyzing Search and Sort In these notes we analyze search and sort. Counting Operations When we analyze the complexity of procedures we re determine the order of the number of
More informationLecture 10: Introduction to Correctness
Lecture 10: Introduction to Correctness Aims: To look at the different types of errors that programs can contain; To look at how we might detect each of these errors; To look at the difficulty of detecting
More informationUsable Privacy and Security Introduction to HCI Methods January 19, 2006 Jason Hong Notes By: Kami Vaniea
Usable Privacy and Security Introduction to HCI Methods January 19, 2006 Jason Hong Notes By: Kami Vaniea Due Today: List of preferred lectures to present Due Next Week: IRB training completion certificate
More informationCSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010
CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion Tyler Robison Summer 2010 1 Toward sharing resources (memory) So far we ve looked at parallel algorithms using fork-join
More informationFoundations, Reasoning About Algorithms, and Design By Contract CMPSC 122
Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More information9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?
Page: 1 of 14 1 R1 And this is tell me what this is? 2 Stephanie x times y plus x times y or hm? 3 R1 What are you thinking? 4 Stephanie I don t know. 5 R1 Tell me what you re thinking. 6 Stephanie Well.
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationUnit Testing as Hypothesis Testing
Unit Testing as Hypothesis Testing Jonathan Clark September 19, 2012 You should test your code. Why? To find bugs. Even for seasoned programmers, bugs are an inevitable reality. Today, we ll take an unconventional
More informationChapter 1 Introduction
Chapter 1 Introduction Why I Am Writing This: Why I am I writing a set of tutorials on compilers and how to build them? Well, the idea goes back several years ago when Rapid-Q, one of the best free BASIC
More informationSTAUNING Credit Application Internet Sales Process with /Voic Templates to Non-Responsive Prospects 2018 Edition
STAUNING Credit Application Internet Sales Process with Email/Voicemail Templates to Non-Responsive Prospects 2018 Edition Contents 30-DAY CREDIT APPLICATION INTERNET SALES PROCESS... 2 DAY 1 AUTO-RESPONSE
More informationHello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications
Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this
More informationFunctions, Pointers, and the Basics of C++ Classes
Functions, Pointers, and the Basics of C++ Classes William E. Skeith III Functions in C++ Vocabulary You should be familiar with all of the following terms already, but if not, you will be after today.
More informationXP: Backup Your Important Files for Safety
XP: Backup Your Important Files for Safety X 380 / 1 Protect Your Personal Files Against Accidental Loss with XP s Backup Wizard Your computer contains a great many important files, but when it comes to
More information2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...
Remembering numbers (and other stuff)... Let s talk about one of the most important things in any programming language. It s called a variable. Don t let the name scare you. What it does is really simple.
More informationCS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class
CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount
More information(Refer Slide Time: 00:01:30)
Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology, Madras Lecture - 32 Design using Programmable Logic Devices (Refer Slide Time: 00:01:30)
More information(Refer Slide Time: 1:27)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data
More informationBurning CDs in Windows XP
B 770 / 1 Make CD Burning a Breeze with Windows XP's Built-in Tools If your PC is equipped with a rewritable CD drive you ve almost certainly got some specialised software for copying files to CDs. If
More informationB. What strategy (order of refactorings) would you use to improve the code?
{ return title.gettext(); public boolean needssplit() { return costlabel.gettext().equals(" >3 "); public boolean needsestimate() { return costlabel.gettext().equals("? "); Challenges PG-1. Smells. A.
More information6.001 Notes: Section 17.5
6.001 Notes: Section 17.5 Slide 17.5.1 Now, let's look at one example in which changing the evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how
More informationKeep Track of Your Passwords Easily
Keep Track of Your Passwords Easily K 100 / 1 The Useful Free Program that Means You ll Never Forget a Password Again These days, everything you do seems to involve a username, a password or a reference
More information1 of 5 3/28/2010 8:01 AM Unit Testing Notes Home Class Info Links Lectures Newsgroup Assignmen [Jump to Writing Clear Tests, What about Private Functions?] Testing The typical approach to testing code
More informationMr G s Java Jive. #11: Formatting Numbers
Mr G s Java Jive #11: Formatting Numbers Now that we ve started using double values, we re bound to run into the question of just how many decimal places we want to show. This where we get to deal with
More informationCS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:
CS 1110, LAB 3: MODULES AND TESTING http://www.cs.cornell.edu/courses/cs11102013fa/labs/lab03.pdf First Name: Last Name: NetID: The purpose of this lab is to help you better understand functions, and to
More informationLutheran High North Technology The Finder
Lutheran High North Technology shanarussell@lutheranhighnorth.org www.lutheranhighnorth.org/technology The Finder Your Mac s filing system is called the finder. In this document, we will explore different
More informationThe Benefits of SMS as a Marketing and Communications Channel From The Chat Bubble written by Michael
The Benefits of SMS as a Marketing and Communications Channel 1 Why companies and organizations should do SMS. We re going to talk through from an organization or marketers point of view, what SMS is good
More informationClose Your File Template
In every sale there is always a scenario where I can t get someone to respond. No matter what I do. I can t get an answer from them. When people stop responding I use the Permission To. This is one of
More informationLaboratory 1: Eclipse and Karel the Robot
Math 121: Introduction to Computing Handout #2 Laboratory 1: Eclipse and Karel the Robot Your first laboratory task is to use the Eclipse IDE framework ( integrated development environment, and the d also
More informationRescuing Lost Files from CDs and DVDs
Rescuing Lost Files from CDs and DVDs R 200 / 1 Damaged CD? No Problem Let this Clever Software Recover Your Files! CDs and DVDs are among the most reliable types of computer disk to use for storing your
More information2016 All Rights Reserved
2016 All Rights Reserved Table of Contents Chapter 1: The Truth About Safelists What is a Safelist Safelist myths busted Chapter 2: Getting Started What to look for before you join a Safelist Best Safelists
More informationProblem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur
Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Introduction to Programming Language Concepts
More informationIf Statements, For Loops, Functions
Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements
More informationTEST-DRIVEN DEVELOPMENT
tdd 2003/6/10 21:42 page 5 #25 Chapter 1 TEST-DRIVEN DEVELOPMENT To vouch this, is no proof, Without more wider and more overt test -Othello,Act 1 Scene 3 William Shakespeare From programmers to users,
More information6.001 Notes: Section 4.1
6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,
More informationGDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial
A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program
More information1 Jane s dress is... yours. A the same than B the same to C similar than D similar to
Test 5A 1 Jane s dress is... yours. A the same than B the same to C similar than D similar to 2 We ve proved that he was guilty but he... doesn t admit it. A yet B already C still D no longer 3 If I...
More informationClient Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module
Basic Class Design Goal of OOP: Reduce complexity of software development by keeping details, and especially changes to details, from spreading throughout the entire program. Actually, the same goal as
More informationCS112 Lecture: Defining Instantiable Classes
CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:
More information08. DESIGN PRINCIPLES. Originality is Overrated PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT
PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 08. DESIGN PRINCIPLES Originality is Overrated it s not about doing it your way this week is all about doing it the smarter, faster way. Design principle
More informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 4 Shared-Memory Concurrency & Mutual Exclusion
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 4 Shared-Memory Concurrency & Mutual Exclusion Dan Grossman Last Updated: August 2010 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/
More informationVideo 2.1. Arvind Bhusnurmath. Property of Penn Engineering, Arvind Bhusnurmath. SD1x-2 1
Video 2.1 Arvind Bhusnurmath SD1x-2 1 Topics Why is testing important? Different types of testing Unit testing SD1x-2 2 Software testing Integral part of development. If you ship a software with bugs,
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationCSE 142 Su 04 Computer Programming 1 - Java. Objects
Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request
More information(Refer Slide Time: 00:51)
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute Technology, Madras Module 10 E Lecture 24 Content Example: factorial
More informationSearch Lesson Outline
1. Searching Lesson Outline 2. How to Find a Value in an Array? 3. Linear Search 4. Linear Search Code 5. Linear Search Example #1 6. Linear Search Example #2 7. Linear Search Example #3 8. Linear Search
More informationLibrary Website Migration and Chat Functionality/Aesthetics Study February 2013
Library Website Migration and Chat Functionality/Aesthetics Study February 2013 Summary of Study and Results Georgia State University is in the process of migrating its website from RedDot to WordPress
More informationthe NXT-G programming environment
2 the NXT-G programming environment This chapter takes a close look at the NXT-G programming environment and presents a few simple programs. The NXT-G programming environment is fairly complex, with lots
More informationLecture 3: Linear Classification
Lecture 3: Linear Classification Roger Grosse 1 Introduction Last week, we saw an example of a learning task called regression. There, the goal was to predict a scalar-valued target from a set of features.
More information(Refer Slide Time: 1:43)
(Refer Slide Time: 1:43) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology, Madras Lecture - 27 Pattern Detector So, we talked about Moore
More informationPRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 03. REQUIREMENTS CHANGE. I Love You, You re Perfect... Now Change!
PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 03. REQUIREMENTS CHANGE I Love You, You re Perfect... Now Change! You re a hero! The door you built for Todd and Gina was a huge success, and now Doug
More informationOutlook is easier to use than you might think; it also does a lot more than. Fundamental Features: How Did You Ever Do without Outlook?
04 537598 Ch01.qxd 9/2/03 9:46 AM Page 11 Chapter 1 Fundamental Features: How Did You Ever Do without Outlook? In This Chapter Reading e-mail Answering e-mail Creating new e-mail Entering an appointment
More informationSTUDENT LESSON A5 Designing and Using Classes
STUDENT LESSON A5 Designing and Using Classes 1 STUDENT LESSON A5 Designing and Using Classes INTRODUCTION: This lesson discusses how to design your own classes. This can be the most challenging part of
More information6.001 Notes: Section 8.1
6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything
More informationLecture 2: SML Basics
15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia
More informationExcel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller
Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing
More informationWord: Print Address Labels Using Mail Merge
Word: Print Address Labels Using Mail Merge No Typing! The Quick and Easy Way to Print Sheets of Address Labels Here at PC Knowledge for Seniors we re often asked how to print sticky address labels in
More informationReliable programming
Reliable programming How to write programs that work Think about reliability during design and implementation Test systematically When things break, fix them correctly Make sure everything stays fixed
More informationUnit 9 Tech savvy? Tech support. 1 I have no idea why... Lesson A. A Unscramble the questions. Do you know which battery I should buy?
Unit 9 Tech savvy? Lesson A Tech support 1 I have no idea why... A Unscramble the questions. 1. which battery / Do you know / should / buy / I? Do you know which battery I should buy? 2. they / where /
More informationFOR Loops. Last Modified: 01 June / 1
FOR Loops http://people.sc.fsu.edu/ jburkardt/isc/week04 lecture 08.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt Department of Scientific Computing
More informationJava/RealJ Troubleshooting Guide
Java/RealJ Troubleshooting Guide by Bob Clark / Sharon Curtis / Simon Jones, September 2000 Some of these tips you will come across during your practical sessions, however we felt it would be helpful to
More informationIntermediate Cucumber. CSCI 5828: Foundations of Software Engineering Lecture 17 03/13/2012
Intermediate Cucumber CSCI 5828: Foundations of Software Engineering Lecture 17 03/13/2012 1 ReadyTalk Recruiting Event The ACM Student Chapter is hosting a recruiting event by a local Denver start-up
More information(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017
Integrated Introduction to Computer Science Hughes (Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017 Contents 1 Announcements 1 2 Evaluation Correction 1 3 Lists 2
More informationTrombone players produce different pitches partly by varying the length of a tube.
Trombone players produce different pitches partly by varying the length of a tube. 7 Variables A variable is a connection between a name and a value.* That sounds simple enough, but some complexities arise
More information