1 / 42

Lecture 4: VALIDATING Your Design

Why should I learn about marketing ? I’m in CSC to avoid this!. MKT 101 – Introduction to Marketing. Lecture 4: VALIDATING Your Design. Today’s Goal. Learn to validate & fix designs before coding What matters in comments & how these can help

silas
Download Presentation

Lecture 4: VALIDATING Your Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Why should I learn about marketing? I’m in CSC to avoid this! MKT 101 – Introduction to Marketing Lecture 4:VALIDATING Your Design

  2. Today’s Goal • Learn to validate & fix designs before coding • What matters in comments & how these can help • Techniques & tricks to avoid writing useless code • Javadoc v. regular comments: why have both? • Why both types of comments rely on marketing • Why is this vital for testing the proposed solution?

  3. Today’s Goal • Learn to validate & fix designs before coding • What matters in comments & how these can help • Techniques & tricks to avoid writing useless code • Javadoc v. regular comments: why have both? • Why both types of comments rely on marketing • Why is this vital for testing the proposed solution? Weeks of coding makes up for minutes of planning

  4. How My Homies Roll

  5. How My Homies Roll Already made #YouSucka trending topic

  6. Reactions to Your Code Passion Threshold Suck Threshold

  7. Reactions to Your Code Passion Threshold Suck Threshold

  8. Reactions to Your Code Passion Threshold Suck Threshold

  9. Intuitive Is Key • Making people think is preying on their weakness • Explicitly state details needed to use code • People will assume that everything has purpose • Male nipples, appendix, Matt still talked about • If it serves no purpose, why would it be created? • Guessing game createdfrom unused parameters • Don't make user probe what return value means

  10. Intuitive Is Key It returned 5. What the $#&@#* does5mean? • Making people think is preying on their weakness • Explicitly state details needed to use code • People will assume that everything has purpose • Male nipples, appendix,Mattstill talked about • If it serves no purpose, why would it be created? • Guessing game created from unused parameters • Don't make user probewhat return value means

  11. Intuitive Is Key I DEFINITELY need another drink… • Making people think is preying on their weakness • Explicitly state details needed to use code • People will assume that everything has purpose • Male nipples, appendix,Mattstill talked about • If it serves no purpose, why would it be created? • Guessing game created from unused parameters • Don't make user probewhat return value means

  12. What To Do With Your Design • Move on to next step: write your javadoc • Validate your thinking by forcing communication • Performs test that you are clear what method does • Team development easier, since method use known • If done well, will find helps develop 1st test set

  13. What To Do With Your Design • Move on to next step: write your javadoc • Validate your thinking by forcing communication • Performs test that you are clear what method does • Team development easier, since method use known • If done well, will find helps develop 1sttest set

  14. But We Cannot Document Yet! • Of course, do not yet know details such as… • How method is coded or calls it makes • Which of the class’s fields used within method • How it computes result to get return value • Given an input, why specific algorithm used • javadoc does NOT need & should not include it • You may (or should be asking yourself): Why?

  15. Why Not Include Details? • You writecode once… • This is goal, idea is to solve problems not write code • Writing code is work & laziness means minimizing this • Once code bug free, do not want to look at it again • …but read comments often • If javadoc duplicates code, could just read code • Only provide what users need

  16. Why Not Include Details? • You writecode once… • This is goal, idea is to solve problems not write code • Writing code is work & laziness means minimizing this • Once code bug free, do not want to look at it again • …but read comments often • If javadoc duplicates code, could just read code • Only provide what users need

  17. What Should Comments Say? • javadoc works with design & does not repeat it • For each class what instances do & where to use • What a method does & when it should be called • Given a methods actions, what method’s results are • Meaning of return values & any special “magic” values • For each real error: when exception will be thrown • How to call method including examples (with return)

  18. Good javadoc /** * Perform the basic work needed when a button is * pushed. This will illuminate the light in the * button. The first time a button is hit it will * also send a message to the elevator controller. */ public void pushButton() { /* Code goes here… */ }

  19. How Does javadoc Test Design? • What if do not know enough to write javadoc? • Can you write code you cannot describe what it does?

  20. How Does javadoc Test Design? • What if do not know enough to write javadoc? • Can you write code you cannot describe what it does? Hint:

  21. How Does javadoc Test Design? • What if do not know enough to write javadoc? • Can you write code you cannot describe what it does? Hint: Your Design Sucks Donkey Balls

  22. Is This Method Really Usable?

  23. Is This Method Really Usable?

  24. What is the Goal Again? • Javadoc!= Java and should not be confused • If comments are good, easier to understand than Java • Only details users need to use method or class • For this to work must make sell its simplicity • Show important connections to well-known examples @see class @see #method @see class#method • Explicitly state any "magic" param or return values • Provide examplesto clarify how it will work

  25. Now This I Can Use

  26. Now This I Can Use

  27. Now This I Can Use

  28. Other Details To Describe • State all assumptions to prevent future bugs • When calling this method, what else will happen?

  29. Other Details To Describe • State all assumptions to prevent future bugs • When calling this method, what else will happen? • Any assumptions upon which method relies

  30. Other Details To Describe • State all assumptions to prevent future bugs • When calling this method, what else will happen? • Any assumptions upon which method relies • Once method completes, details needed for later

  31. Programming By Contract • Precondition true at start when method called • Ensuring these met responsibility of calling method • Postconditions true at end of the method call • Guaranteeing this responsibility of called method • Only if preconditions met must this happen, however

  32. Programming By Contract • Precondition true at start when method called • Ensuring these met responsibility of calling method • Postconditions true at end of the method call • Guaranteeing this responsibility of called method • Only if preconditions met must this happen, however

  33. Good Javadoc Example /** * Perform the basic work needed when a button is * pushed. This will illuminate the light in the * button. The first time a button is hit it will * also send a message to the elevator controller.<br/> * * Precondition: lit.isOff(); controller is set<br/> * * Postcondition: !lit.isOff() && * request sent to elevator controller */public void pushButton() {}

  34. What's Next? • Could start to write code at this point in project • But doing this means still may find many bugs • Fixing these hard if calling many other methods • Ideal if we could 1stcheck that method actually works • Remember key trait of successful programmers

  35. Successful Programmers • Could start to write code at this point in project • But doing this means still may find many bugs • Fixing these hard if calling many other methods • Ideal if we could 1stcheck that method actually works • Remember key trait of successful programmers

  36. Outlining a Method • Write pseudocodeoutline of how method works • Can be written assuming other methods they work • Can ignore coding details, so simpler & easier to write • Once done writing, tests check algorithm works • Fix errors BEFORE coding to limit debugging needs • Can then make the algorithm into comments • Check code against comment, since that passed tests • Plain English description makes reading code easier

  37. Outlining a Method • How to write algorithm: what details important? • Can skip punctuation of any sort:this is not code • Should include major loops, but can write in English • Important to translate: each action to take is explicit • Can write “swap values” or group assignments • Using shorthand fine, but translation to code clear

  38. Pseudocode Needs More Detail

  39. Pseudocode Needs Less Detail

  40. Heated Handlebars

  41. Heated Handlebars

  42. For Next Lecture • Week #2 homework available on Angel page • Due by 5:00PM Tuesday • Submit assignment via e-mail & (possibly) paper • Reading for Friday linked to from Angel schedule • Discuss range of possible tests to perform • How often to test code as we are writing it • Present methods of handling failed test

More Related