1 / 11

Chapter 6: While you were Coding

Chapter 6: While you were Coding. Presented by: Ben Palermo Nathan O’Grady. Programming by Coincidence . How to Program by Coincidence Accidents of Implementation It may just look like its working The boundary conditions may be an accident

bian
Download Presentation

Chapter 6: While you were Coding

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. Chapter 6: While you were Coding Presented by: Ben Palermo Nathan O’Grady

  2. Programming by Coincidence • How to Program by Coincidence • Accidents of Implementation • It may just look like its working • The boundary conditions may be an accident • Behavior may change with the next library release • Superfluous code makes execution time longer • Extra calls increases the chances of new bugs • Accidents of Context • Implicit Assumptions

  3. How to program deliberately • Be aware of what you are doing • Understand the project and the language • Use a plan • Only rely on what you know for sure • If you must assume, document it • Test your assumptions, as well as your code • Spend time on the important things • Do not be afraid to rewrite existing code

  4. Algorithm Speed • O() notation • Estimation • Simple Loops • Nested Loops • Binary Chop • Divide and Conquer • Combinatoric • Algorithm speed in practice

  5. Refactoring • What is refactoring? • When to refactor • When two units perform the same action • Non-orthogonal design • New requirements or a better understanding of the problem • Improving performance

  6. Refactoring • Complications • Pressure to release a product • Refactor early, refactor often

  7. Refactoring • How to refactor • Refactoring is redesign • Don’t refactor and add functionality • Establish good tests before refactoring • Make small, deliberate changes • Test after each change • Let refactoring changes break old builds

  8. Testing Code • Unit Testing • Testing done on individual modules in isolation to each other • Creates artificial environment, then tests output based on known values

  9. Testing Code • Using contracts • Design unit tests to check that a contract is fulfilled • Test modules in a bottom-up approach • Design code to be tested (i.e. design with contracts in mind)

  10. Testing Code • Writing Unit Tests • Include in main source code • As a separate, normally unused function • Use test harnesses • JUnit test cases • Composable tests • Include a debugging window in final build • Culture of Testing

  11. Evil Wizards • Don’t use wizard code you don’t understand. • Be able to write wizard code without the wizard.

More Related