13-Jul-15 Effective Programming. “The new US stealth fighter, the F-22 Raptor, was deployed for the first time to Asia earlier this month. On Feb. 11,

Slides:



Advertisements
Similar presentations
The Sales Presentation
Advertisements

Test process essentials Riitta Viitamäki,
PHILOSOPHY OF CODING. An untidy room is like bad code: you spend hours in finding things and when you try to add something you are just adding mess.
Lecture 19. Reduction: More Undecidable problems
1 Pipelining Part 2 CS Data Hazards Data hazards occur when the pipeline changes the order of read/write accesses to operands that differs from.
The Cathedral and the Bazaar: A Look at Open-Source ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Week 5: Loops 1.  Repetition is the ability to do something over and over again  With repetition in the mix, we can solve practically any problem that.
Software Quality Assurance Inspection by Ross Simmerman Software developers follow a method of software quality assurance and try to eliminate bugs prior.
Regression Wisdom.
Debugging Introduction to Computing Science and Programming I.
Motivation Lecture Master seminar, January Contents Introduction Importance of regular work Theses with programming Publishing your work Conclusion.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Debugging CPSC 315 – Programming Studio Fall 2008.
JUnit, Revisited 17-Apr-17.
Computer Engineering 203 R Smith Agile Development 1/ Agile Methods What are Agile Methods? – Extreme Programming is the best known example – SCRUM.
1 Psych 5500/6500 The t Test for a Single Group Mean (Part 5): Outliers Fall, 2008.
Midterm Logistics Where? 2050 VLSB When? Monday, 4:10 to 5:40 What to do? –“Review problems” from Thursday/Friday in UCWise. –Two practice exams and solutions.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Introduction to Software Engineering CS-300 Fall 2005 Supreeth Venkataraman.
SW Testing - part of a better Process CERN-BE-BI-SW Training Day M.Andersen.
Completing the Accounting Cycle. The Adjustment Process  At the end of a fiscal period, we have to make sure that all our financial statements are 100%
19-Aug-15 JUnit tests for output. Capturing output System.out.print and System.out.println usually “print” to the screen, but you can change that OutputStream.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Week 14 - Monday.  What did we talk about last time?  Image manipulation  Inheritance.
Significance Testing 10/15/2013. Readings Chapter 3 Proposing Explanations, Framing Hypotheses, and Making Comparisons (Pollock) (pp ) Chapter 5.
As you arrive… Get you laptop out and get ready to program some python Go to the course website and load all the example programs that are posted there.
Testing in Extreme Programming
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Testing Michael Ernst CSE 140 University of Washington.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
Making a great Project 2 OCR 1994/2360. Analysis This is the key to getting it right. Too many candidates skip through this section. It’s worth 20% of.
NOTES The Normal Distribution. In earlier courses, you have explored data in the following ways: By plotting data (histogram, stemplot, bar graph, etc.)
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
Software Engineering Experimentation Rules for Reviewing Papers Jeff Offutt See my editorials 17(3) and 17(4) in STVR
Social Media Roundup Bad social media: 7 Ways to lose your audience.
Lab 10: Project and Code Organization User Interface Lab: GUI Lab Oct. 18 th, 2014.
Ethics of Software Testing Thomas LaToza CS 210 Final Presentation 12 / 2 / 2002.
Fraction Easy for you!!
Debugging Strategies from Software Carpentry. Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going.
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
1 The Practice of Computing Using PYTHON William PunchRichard Enbody Chapter 3 Algorithms & Program Development Copyright © 2011 Pearson Education, Inc.
Chapter 7 The Practices: dX. 2 Outline Iterative Development Iterative Development Planning Planning Organizing the Iterations into Management Phases.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
Week 14 - Monday.  What did we talk about last time?  Inheritance.
1 Algorithms  Algorithms are simply a list of steps required to solve some particular problem  They are designed as abstractions of processes carried.
Fixing the Defect CEN4072 – Software Testing. From Defect to Failure How a defect becomes a failure: 1. The programmer creates a defect 2. The defect.
CS 350 – Software Design Expanding Our Horizons – Chapter 8 The traditional view of objects is that they are data with methods. Sometimes objects could.
WATERFALL DEVELOPMENT MODEL. Waterfall model is LINEAR development lifecycle. This means each phase must be completed before moving onto the next!!! WHAT.
Completing the Accounting Cycle. The Adjustment Process  At the end of a fiscal period, we have to make sure that all our financial statements are 100%
Software Construction Lecture 19 Software Testing-2.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
Animation. What is Blender? Blender is an open source 3D modeling program developed by NaN. It was formed in 1998, originally manufactured as shareware.
A significance test or hypothesis test is a procedure for comparing our data with a hypothesis whose truth we want to assess. The hypothesis is usually.
Version Control and SVN ECE 297. Why Do We Need Version Control?
Welcome to Software Project Management. CONVENTIONAL SOFTWARE MANAGEMENT The BEST and WORST thing about software is its flexibility. 1.Software development.
Has Brian Kernighan’s thoughts on prototype vs. production programming.
29-Jun-16 Effective Programming. “The new US stealth fighter, the F-22 Raptor, was deployed for the first time to Asia earlier this month. On Feb. 11.
By: Antonio Vazquez.  As far as this year goes, there were a lot of struggles that I had this year, I can’t really explain why, they just occurred. 
Testing UW CSE 160 Winter 2017.
Testing UW CSE 160 Winter 2016.
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
Testing and debugging A short interlude 2-Dec-18.
Effective Programming
Effective Programming
CS 240 – Advanced Programming Concepts
Testing and debugging A short interlude 17-Apr-19.
Presentation transcript:

13-Jul-15 Effective Programming

“The new US stealth fighter, the F-22 Raptor, was deployed for the first time to Asia earlier this month. On Feb. 11, twelve Raptors flying from Hawaii to Japan were forced to turn back when a software glitch crashed all of the F-22s’ on-board computers as they crossed the international date line...every fighter completely lost all navigation and communications when they crossed the international date line. They reportedly had to turn around and follow their tankers by visual contact back to Hawaii...if they had not been with their tankers, or the weather had been bad, this would have been serious.” Why test?

Program design “In preparing for battle I have always found that plans are useless, but planning is indispensable.” --Dwight D. Eisenhower The same is true in programming You must plan out your program in advance, so you know where you are trying to go--but expect many changes along the way Don’t just jump into coding with the first approach that occurs to you, but consider alternate plans Always be ready to refactor as needed “How far you can go without destroying from within what you are trying to defend from without?” --Dwight D. Eisenhower Actually, I don’t think this quote has any relevance to programming

Why refactor? Refactoring: Making changes to your program that don’t affect what the program does Some refactorings: The name of a method no longer accurately describes what it does, so you want to rename it You need more control over what a method does, so you want to add a parameter You need to use only part of what a method does, so you extract that part into a separate method You realize that a method is in the wrong class, so you move it to a different class Eclipse makes these and other refactorings relatively “safe”-- that is, they are unlikely to break your program Not all refactorings are as easy

Regression testing Regression testing: Testing whether the program still works, after you have made a change to it JUnit tests are extremely useful for regression testing A thorough set of tests gives you the confidence to refactor Debugging is dangerous--fixing a bug is very likely to introduce new bugs It is a general rule that the difficulty of debugging a program goes up as the square of the program size

Programming discipline To write impressively good programs, here are some rules to follow Plan ahead--consider more than one design before you start programming Refactor early and often Test everything you can as thoroughly as you can--don’t let the code get out of control Writing tests before you write the code isn’t the only way to program, but it improves your program design as well as your code Start with “the simplest thing that could possibly work” Insofar as possible, make only small changes to your program Don’t add features until the code you already have is “completely” debugged It takes discipline to follow these rules--it’s easier to just jump in and start writing code--but a methodical approach greatly increases your chance of success

Dealing with I/O We can (in some cases) test our output methods PrintStream originalOut = System.out; OutputStream os = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(os); System.setOut(ps); We can even test our input methods InputStream originalIn = System.in; byte[] buf = "Some input string".getBytes(); InputStream is = new ByteArrayInputStream(buf); System.setIn(is);

Dealing with GUIs GUIs are not easy to test with JUnit-like software There are programs that attempt to provide automatic JUnit tests for GUIs, but I haven’t found any I like If you want to write a GUI testing framework, you should explore java.awt.Robot There is a reasonably good, albeit not perfect, solution to the problem of testing GUIs... Don’t do any work in the GUI class! Use the MVC (Model-View-Controller) approach The GUI should only communicate between the user and the model Of course, this is easier said than done, but still.... Even if a GUI “works,” that doesn’t make it easy to use Of course you think your GUI is obvious You should always have at least one other person try it out without help from you--you will probably be surprised at the result

Creeping featurism “Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” --Antoine de Saint-Exupery In my opinion (as you already know), the highest praise you can give to a program is to say “it just works” Unfortunately, most software competes on the basis of how many features it offers Sometimes you need those features When you don’t need them, you are better off without them

The End The original study that showed huge variations in individual programming productivity was conducted in the late 1960s by Sackman, Erikson, and Grant (1968). They studied professional programmers with an average of 7 years’ experience and found that the ratio of intitial coding time between the best and worst programmers was about 20:1; the ratio of debugging times over 25:1; of program sizes 5:1; and of program execution speed about 10:1. They found no relationship between a programmer’s amount of experience and code quality or productivity. -- Code Complete, page 548