Reviewing your Program CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.4 © Mitchell Wand, 2012-2014 This work is licensed under a Creative Commons.

Slides:



Advertisements
Similar presentations
Lecture 5: Requirements Engineering
Advertisements

When do I need an invariant? CS 5010 Program Design Paradigms “Bootcamp” Lesson 7.4 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Depth-First and Breadth-First Search CS 5010 Program Design Paradigms “Bootcamp” Lesson 9.2 TexPoint fonts used in EMF. Read the TexPoint manual before.
Templates CS 5010 Program Design Paradigms “Bootcamp” Lesson
Contracts, Purpose Statements, Examples and Tests CS 5010 Program Design Paradigms “Bootcamp” Lesson 1.6 TexPoint fonts used in EMF. Read the TexPoint.
Sometimes Structural Recursion Isn't Enough CS 5010 Program Design Paradigms “Bootcamp” Lesson 8.1 TexPoint fonts used in EMF. Read the TexPoint manual.
Two Draggable Cats CS 5010 Program Design Paradigms “Bootcamp” Lesson 3.4 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Real State vs. Simulated State CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.3 © Mitchell Wand, This work is licensed under a Creative.
Lists vs. Structures CS 5010 Program Design Paradigms “Bootcamp” Lesson 6.1 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
1 JOB APPLICATION DOS AND DON ’ TS Patricia Crawford WBL Coordinator.
The 8-queens problem CS 5010 Program Design Paradigms “Bootcamp” Lesson 9.3 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this.
Foldr and Foldl CS 5010 Program Design Paradigms “Bootcamp” Lesson 7.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Powerful Proofreading Developed By Elisa P. Paramore Student Support Services Counselor.
Powerful Proofreading
Function Composition CS 5010 Program Design Paradigms “Bootcamp” 1 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
The Function Design Recipe CS 5010 Program Design Paradigms “Bootcamp” Lesson 1.1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Midterm Review CS 5010 Program Design Paradigms “Bootcamp” Lesson 9.4 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
 Before you submit your paper, check these things.
Ormap, andmap, and filter CS 5010 Program Design Paradigms “Bootcamp” Lesson 5.3 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Function Composition CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a Creative Commons.
Structural Decomposition CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.1 © Mitchell Wand, This work is licensed under a Creative Commons.
Sales letter Ms. Debs f. dianco. WHAT IS A SALES LETTER? = It is a document designed to generate sales. = It persuades the reader to place an order; to.
Lesson 9: Peer Review Topics Role of the Peer Reviewer
Patterns of Communication Between Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.1 © Mitchell Wand, This work is licensed under.
Solving Your Problem by Generalization CS 5010 Program Design Paradigms “Bootcamp” Lesson 7.1 © Mitchell Wand, This work is licensed under a.
The California Writing Exam Grades 4 and 7
Finishing the Data Definition Recipe CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.4 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
The Data Design Recipe CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a Creative Commons.
The Function Design Recipe CS 5010 Program Design Paradigms “Bootcamp” Lesson 1.1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Lily  It is the kind of writing used in high school and college classes.  Academic writing is different from creative writing, which is the kind.
Examining Two Pieces of Data CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a Creative.
The Design Recipe using Classes CS 5010 Program Design Paradigms "Bootcamp" Lesson 10.5 © Mitchell Wand, This work is licensed under a Creative.
Design Strategies 1: Combine Simpler Functions CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed.
The Point of This Course CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.1 © Mitchell Wand, This work is licensed under a Creative Commons.
Generalizing Over Functions CS 5010 Program Design Paradigms “Bootcamp” Lesson TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Solving Your Problem by Generalization CS 5010 Program Design Paradigms “Bootcamp” Lesson 7.1 © Mitchell Wand, This work is licensed under a.
The Design Recipe using Classes CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative.
Organization of This Course CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.2 © Mitchell Wand, This work is licensed under a Creative Commons.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Midterm Review CS 5010 Program Design Paradigms “Bootcamp” Lesson TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Solving Your Problem by Generalization CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under.
Contracts, Purpose Statements, Examples and Tests
CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.2
The Point of This Course
Generalizing Similar Functions
CS 5010 Program Design Paradigms “Bootcamp” Lesson 5.2
Examining Two Pieces of Data
CS 5010 Program Design Paradigms "Bootcamp" Lesson 9.4
CS 5010 Program Design Paradigms “Bootcamp” Lesson 1.3
Introduction to Invariants
Reviewing your Program
CS 5010 Program Design Paradigms “Bootcamp” Lesson 8.7
CS 5010 Program Design Paradigms “Bootcamp” Lesson 4.1
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
CS 5010 Program Design Paradigms “Bootcamp” Lesson 3.4
Solving Your Problem by Generalization
Contracts, Purpose Statements, Examples and Tests
CS 5010 Program Design Paradigms “Bootcamp” Lesson 6.5
More examples of invariants
ormap, andmap, and filter
Generalizing Similar Functions
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Rewriting your function using map and foldr
Introduction to Universe Programs
Examining Two Pieces of Data
When do I need an invariant?
CS 5010 Program Design Paradigms “Bootcamp” Lesson 3.4
Presentation transcript:

Reviewing your Program CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.4 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Creative Commons Attribution-NonCommercial 4.0 International License 1

Introduction A program is like an essay or term paper. You wouldn't turn in a term paper without proofreading it for typos, checking for spelling, and generally making improvements. So you shouldn't turn in your program without checking it over and seeing if it can be improved. Our goal is to write beautiful programs– programs which are easily read and understood by others. 2

The Program Review Recipe On the next slide is a list of things to check in your program. Then we'll go through each of the items in more detail. 3

The Program Review Recipe 1. Do all the tests pass? 2. Are the contracts accurate? 3. Are the purpose statements and interpretations clear and accurate? 4. Are there ugly pieces of code that should be broken out into their own functions? 5. Are there pieces of code that are duplicated (or almost duplicated) and should be made into independent functions?

1. Do all the tests pass? Of course you wouldn't turn in a program if some your tests failed, but... – Did you achieve 100% code coverage? – Are your tests readable? – Are there comments or error messages so that the TA will be able to see the purpose of each test? – Are the tests written so that the TA can easily see that each test actually tests what it claims to test? 5

2. Are the contracts accurate? Are all the type names spelled correctly and consistently? Do the contract and function definition agree on the number and types of the arguments, and on the type of the result – Maybe you discovered along the way that you had to change some of the arguments. Make sure that you've changed the contract to match. 6

3. Are the purpose statements clear and accurate? Each purpose statement is a set of short noun phrases describing what the function is supposed to return. – They generally take the form GIVEN/RETURNS, where each of these keywords is followed by a short noun phrase. – The RETURNS clause must at least mention every one of the function arguments. 7

Review: what makes a good purpose statement? It gives more information than just the contract. For example GIVEN: a Number and a Boolean RETURNS: a Number is not a good purpose statement It is specific. Ideally, a reader should be able to figure out what a function returns just by reading the purpose statement – perhaps along with examples, other documentation, etc. – but WITHOUT reading the code!

Writing good purpose statements can be hard. Sometimes the arguments are the components of some thing, rather than the thing itself. – Here's a useful example: GIVEN: the x-coordinate, y-coordinate, and direction of some robot RETURNS: the robot moved forward by 10 pixels. – You may find this to be a good pattern in many examples. 9

Spelling Counts Spelling Counts. Always. Everywhere. Spelling errors show a lack of professionalism. They tell the reader that you are SLOPPY and you DON'T CARE. If you have a spelling error in your resume or cover letter, you will NOT get the job. 10

Reviewing your purpose statements (cont'd) Check your purpose statements for spelling. Make sure you are consistent and correct about English singular and plural. Try to use English articles, like "a" and "the", correctly. – this may be difficult if your first language does not have these. If English is not your first language, go find the best English-speaker you know and get help. – We are officially allowing this. 11

The same things hold for data definitions Go back and review your data definitions, too. Check over the English in your interpretations. Check the other items that you were supposed to review— – Here's the recipe, from Lesson

Reviewing a Data Design 1. Is the interpretation clear and unambiguous? 2. Can you represent all the information you need for your program? 3. Do you need all of the data in your representation? 4. Does every combination of values make sense? If not, document the meaningful combinations with a WHERE clause. 13

4. Are there ugly pieces of code that should be broken out into their own functions? Remember: one function = one task If there is complicated stuff in your function definition, replace it by a call to a help function. That way you can document what that stuff is supposed to do, and test it. 14

5. Are there pieces of code that are duplicated (or almost duplicated) and should be made into independent functions? We strive for no duplicated code. If there's a subtask that gets done several times, turn it into a function that you can document and test. We'll have much more to say about this in coming weeks. 15 Principle: "Don't Repeat Yourself"

Summary Our goal is to write not just working programs, but beautiful programs. We've given you a list of things to check before you turn in your program. Fixing these things will make your program more pleasant for the reader, whether that is your TA, your boss, or your successor at your job. 16

Next Steps If you have questions about this lesson, ask them on the Discussion Board Go on to the next lesson 17