<commit_before>---
layout: section
title: How to Verify and Validate Research Code as You Work
---


##Warmup discussion:

 - Validation v. Verification
 - How to test "correctness."
 - Why allow user error v. Writing highly detailed API? 

##Testing:

##Before you compile:
 - Documentation within code
 - Debugging with IDE
 - Test driven development: how do we "black box" a component of our code?
 - Throwing exceptions
 - Testing by hand
 - Incorporating test code 
 - Testing for codes involving random variables (e.g. Dependency injection, delegation)

##After Compiling
 - Edge Cases
 - Devising Tests


##Test driven development
 - Core principles: only write code if it is used to pass previously failed test, eliminate duplication
 - how to "black box" components of code, while still compiling 
 - how to phrase a coding project as a series of tests
 - coding cycle: devise test, write code to pass test, clean up, repeat
 - Kent beck reference



##Review Excercises
 - Hand students code known to have flaws, ask them to find flaws
 - Exchange code and test/debug
 - Evaluate third party software


##Ex.1 Hand off codes with model bug, they write tests

(Potential contest: which team can find flaw first)

-(easy) weather calculations: Solution: pV = nRT, code not prepared for T = 0
<commit_msg>Update testing.md<commit_after>---
layout: section
title: How to Verify and Validate Research Code as You Work
---


##Warmup discussion:

 - Validation v. Verification
 - How to test "correctness."
 - Why allow user error v. Writing highly detailed API? 

##Testing:

##Before you compile:
 - Documentation within code
 - Debugging with IDE
 - Throwing exceptions
 - Testing by hand
 - Incorporating test code 
 - Testing for codes involving random variables (e.g. Dependency injection, delegation)

##After Compiling
 - Edge Cases
 - Devising Tests


##Test driven development
 - Core principles: only write code if it is used to pass previously failed test, eliminate duplication
 - how to "black box" components of code, while still compiling 
 - how to phrase a coding project as a series of tests
 - coding cycle: devise test, write code to pass test, clean up, repeat
 - Kent beck reference



##Review Excercises
 - Hand students code known to have flaws, ask them to find flaws
 - Exchange code and test/debug
 - Evaluate third party software


##Ex.1 Hand off codes with model bug, they write tests

(Potential contest: which team can find flaw first)

-(easy) weather calculations: Solution: pV = nRT, code not prepared for T = 0

{'fraction_non_alphanumeric': 0.06658832745789267, 'fraction_numerical': 0.0015667841754798276, 'mean_word_length': 3.652094717668488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2848812', 'n_tokens_mistral': 693, 'n_tokens_neox': 646, 'n_words': 360}