diff --git a/lesson_plans/20231110_overview.txt b/lesson_plans/20231110_overview.txt deleted file mode 100644 index 58c1740..0000000 --- a/lesson_plans/20231110_overview.txt +++ /dev/null @@ -1,47 +0,0 @@ -# 1. Big Picture -## 5. What is mastery in programming? -## 8. How to do better? -## 14. Questions about `assert` -# 2. Express your assumptions in code -## Slide 16: Problem -## 18. Question about functions -## 24. Question about functions -# 3. Express yourself in readable code -## 29. Questions 1 -## 31. Questions 2 -## 34. Question 3 -## 36. Question 4 -## 38. Question 5 -## 40. Question 6 -## 42. Question 7 -## 44. Question 8 -## 46. Questions about function names? -# 4. Making your code readable -## 48. We were all kids once -## 49. Your first code -# 5. Do work in the right order -## 56. Question 1 -## 58. Question 2 -## 60. Question 3 -## 62. Question 4 -## 64. Question 5 -## 66. Question 6 -## 68. Questions about function testing? -# 6. Make your function usable by others -## 71. Questions about function documentation? -# 7. Writing the function body -## 73. When is a function body good enough? -## 76. Questions about writing a function body? -# 8. Expressing a set -## 79. What is set? -## 81. Question -## 83. Question -## 86. Questions about sets? -# 9. Expressing a dictionary -## 88. Trick question -## 91. Questions about dictionaries? -# 10. Using system arguments -## 94. Problem -## 96. Exercise, little help -## 99. Questions about command line arguments? -## 101. Questions about today’s theory? diff --git a/lesson_plans/20231110_reflection.md b/lesson_plans/day_3/20231110_reflection.md similarity index 100% rename from lesson_plans/20231110_reflection.md rename to lesson_plans/day_3/20231110_reflection.md diff --git a/lesson_plans/20231110_richel.md b/lesson_plans/day_3/20231110_richel.md similarity index 100% rename from lesson_plans/20231110_richel.md rename to lesson_plans/day_3/20231110_richel.md diff --git a/lesson_plans/check_python_style.sh b/lesson_plans/day_3/check_python_style.sh similarity index 100% rename from lesson_plans/check_python_style.sh rename to lesson_plans/day_3/check_python_style.sh diff --git a/lesson_plans/day_3.bib b/lesson_plans/day_3/day_3.bib similarity index 100% rename from lesson_plans/day_3.bib rename to lesson_plans/day_3/day_3.bib diff --git a/lesson_plans/day_3.qmd b/lesson_plans/day_3/day_3.qmd similarity index 100% rename from lesson_plans/day_3.qmd rename to lesson_plans/day_3/day_3.qmd diff --git a/lesson_plans/day_3.sh b/lesson_plans/day_3/day_3_schedule_reminder.sh similarity index 100% rename from lesson_plans/day_3.sh rename to lesson_plans/day_3/day_3_schedule_reminder.sh diff --git a/lesson_plans/dilbert_agile_1.png b/lesson_plans/day_3/dilbert_agile_1.png similarity index 100% rename from lesson_plans/dilbert_agile_1.png rename to lesson_plans/day_3/dilbert_agile_1.png diff --git a/lesson_plans/dilbert_agile_2.png b/lesson_plans/day_3/dilbert_agile_2.png similarity index 100% rename from lesson_plans/dilbert_agile_2.png rename to lesson_plans/day_3/dilbert_agile_2.png diff --git a/lesson_plans/dilbert_tdd.gif b/lesson_plans/day_3/dilbert_tdd.gif similarity index 100% rename from lesson_plans/dilbert_tdd.gif rename to lesson_plans/day_3/dilbert_tdd.gif diff --git a/lesson_plans/dilbert_tdd.png b/lesson_plans/day_3/dilbert_tdd.png similarity index 100% rename from lesson_plans/dilbert_tdd.png rename to lesson_plans/day_3/dilbert_tdd.png diff --git a/lesson_plans/dilbert_tdd_2.gif b/lesson_plans/day_3/dilbert_tdd_2.gif similarity index 100% rename from lesson_plans/dilbert_tdd_2.gif rename to lesson_plans/day_3/dilbert_tdd_2.gif diff --git a/lesson_plans/dilbert_tdd_2.png b/lesson_plans/day_3/dilbert_tdd_2.png similarity index 100% rename from lesson_plans/dilbert_tdd_2.png rename to lesson_plans/day_3/dilbert_tdd_2.png diff --git a/lesson_plans/dilbert_tdd_3.png b/lesson_plans/day_3/dilbert_tdd_3.png similarity index 100% rename from lesson_plans/dilbert_tdd_3.png rename to lesson_plans/day_3/dilbert_tdd_3.png diff --git a/lesson_plans/dilbert_tdd_4.png b/lesson_plans/day_3/dilbert_tdd_4.png similarity index 100% rename from lesson_plans/dilbert_tdd_4.png rename to lesson_plans/day_3/dilbert_tdd_4.png diff --git a/lesson_plans/forgetting.png b/lesson_plans/day_3/forgetting.png similarity index 100% rename from lesson_plans/forgetting.png rename to lesson_plans/day_3/forgetting.png diff --git a/lesson_plans/function_cartoon.png b/lesson_plans/day_3/function_cartoon.png similarity index 100% rename from lesson_plans/function_cartoon.png rename to lesson_plans/day_3/function_cartoon.png diff --git a/lesson_plans/render.sh b/lesson_plans/day_3/render.sh similarity index 100% rename from lesson_plans/render.sh rename to lesson_plans/day_3/render.sh diff --git a/lesson_plans/styles.css b/lesson_plans/day_3/styles.css similarity index 100% rename from lesson_plans/styles.css rename to lesson_plans/day_3/styles.css diff --git a/lesson_plans/tdd_cycle_2.jpg b/lesson_plans/day_3/tdd_cycle_2.jpg similarity index 100% rename from lesson_plans/tdd_cycle_2.jpg rename to lesson_plans/day_3/tdd_cycle_2.jpg diff --git a/lesson_plans/tdd_hat_1.jpg b/lesson_plans/day_3/tdd_hat_1.jpg similarity index 100% rename from lesson_plans/tdd_hat_1.jpg rename to lesson_plans/day_3/tdd_hat_1.jpg diff --git a/lesson_plans/tdd_hat_2.jpg b/lesson_plans/day_3/tdd_hat_2.jpg similarity index 100% rename from lesson_plans/tdd_hat_2.jpg rename to lesson_plans/day_3/tdd_hat_2.jpg diff --git a/lesson_plans/test.sh b/lesson_plans/day_3/test.sh similarity index 100% rename from lesson_plans/test.sh rename to lesson_plans/day_3/test.sh diff --git a/lesson_plans/vancouver.csl b/lesson_plans/day_3/vancouver.csl similarity index 100% rename from lesson_plans/vancouver.csl rename to lesson_plans/day_3/vancouver.csl diff --git a/lesson_plans/day_5/20231113_richel.md b/lesson_plans/day_5/20231113_richel.md new file mode 100644 index 0000000..6ebd292 --- /dev/null +++ b/lesson_plans/day_5/20231113_richel.md @@ -0,0 +1,14 @@ +# Lesson plan 2023-11-12 by Richel + +## Learning objectives + + * Being able to use regular expression in a tested function + +## Teacher goals + + * Show TDD in live coding + * Students must code often + +## Plan for today + + * Use the existing exercises, prepare the students for those diff --git a/lesson_plans/day_5/check_python_style.sh b/lesson_plans/day_5/check_python_style.sh new file mode 100755 index 0000000..f14f644 --- /dev/null +++ b/lesson_plans/day_5/check_python_style.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# + +# Ignore the first ruff error +ruff day_3.qmd > temp_ruff_results.txt 2>&1 + +last_line=$(cat temp_ruff_results.txt | tail -n 1) +# echo "last_line: ${last_line}" +n_errors_plus_one=$(echo "${last_line}" | cut -d ' ' -f 2) +# echo "Number of errors plus one: ${n_errors_plus_one}" +n_errors=$((n_errors_plus_one-1)) +echo "Number of errors: ${n_errors}" + +exit ${n_errors} + +# FAILS: will still always give an error +# Remove the part between '---' +#tail -n +11 day_3.qmd > temp_day_3.qmd +#ruff temp_day_3.qmd diff --git a/lesson_plans/day_5/day_5.bib b/lesson_plans/day_5/day_5.bib new file mode 100644 index 0000000..5e76761 --- /dev/null +++ b/lesson_plans/day_5/day_5.bib @@ -0,0 +1,960 @@ +@article{george2004structured, + title={A structured experiment of test-driven development}, + author={George, Boby and Williams, Laurie}, + journal={Information and software Technology}, + volume={46}, + number={5}, + pages={337--342}, + year={2004}, + publisher={Elsevier} +} + +@book{madeyski2010test, + title={Test-driven development: An empirical evaluation of agile practice}, + author={Madeyski, Lech and Gesti{\'o}n de sistemas de informaci{\'o}n}, + year={2010}, + publisher={Springer} +} + +@book{mayr2005projekt, + title={Projekt Engineering: Ingenieurm{\"a}{\ss}ige Softwareentwicklung in Projektgruppen}, + author={Mayr, Herwig}, + year={2005}, + publisher={Hanser Verlag} +} + +@article{nagappan2008realizing, + title={Realizing quality improvement through test driven development: results and experiences of four industrial teams}, + author={Nagappan, Nachiappan and Maximilien, E Michael and Bhat, Thirumalesh and Williams, Laurie}, + journal={Empirical Software Engineering}, + volume={13}, + pages={289--302}, + year={2008}, + publisher={Springer} +} + + + + +@article{abd2018calculating, + title = "Calculating {M}c{C}abe's cyclomatic complexity metric and its effect on the quality aspects of software", + author={Abd Jader, Marwa Najm and Mahmood, Riyadh Zaghlool}, + year={2018} +} + +@article{alkaoud2018quality, + title={Quality metrics of test suites in test-driven designed applications}, + author={Alkaoud, Hessah and Walcott, Kristen R}, + journal={International Journal of Software Engineering Applications (IJSEA)}, + volume={2018}, + year={2018} +} + +@article{azencott2018machine, + title={Machine learning and genomics: precision medicine versus patient privacy}, + author={Azencott, C-A}, + journal={Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences}, + volume={376}, + number={2128}, + pages={20170350}, + year={2018}, + publisher={The Royal Society Publishing} +} + +@article{baggerly2009deriving, + title={Deriving chemosensitivity from cell lines: Forensic bioinformatics and reproducible research in high-throughput biology}, + author={Baggerly, Keith A and Coombes, Kevin R}, + journal={The Annals of Applied Statistics}, + pages={1309--1334}, + year={2009}, + publisher={JSTOR} +} + +@article{barba2016hard, + title={The hard road to reproducibility}, + author={Barba, Lorena A}, + journal={Science}, + volume={354}, + number={6308}, + pages={142--142}, + year={2016}, + publisher={American Association for the Advancement of Science} +} + +@article{barnes2010publish, + title={Publish your computer code: it is good enough}, + author={Barnes, Nick}, + journal={Nature}, + volume={467}, + number={7317}, + pages={753--753}, + year={2010}, + publisher={Nature Publishing Group} +} + +@misc{bbbqarticleissue157, + author = {Richèl J. C. Bilderbeek}, + title = {{BBBQ} article issue 157}, + howpublished = {\url{https://github.com/richelbilderbeek/bbbq_article_issue_157}}, + year = {2021}, + note = {[Accessed 29-May-2022]}, +} + +@book{beck2000extreme, + title={Extreme programming explained: embrace change}, + author={Beck, Kent}, + year={2000}, + publisher={Addison-Wesley Professional} +} + +@article{benureau2018re, + title={Re-run, repeat, reproduce, reuse, replicate: transforming code into scientific contributions}, + author={Benureau, Fabien CY and Rougier, Nicolas P}, + journal={Frontiers in neuroinformatics}, + volume={11}, + pages={69}, + year={2018}, + publisher={Frontiers Media SA} +} + +@inproceedings{bhat2006evaluating, + title={Evaluating the efficacy of test-driven development: industrial case studies}, + author={Bhat, Thirumalesh and Nagappan, Nachiappan}, + booktitle={Proceedings of the 2006 ACM/IEEE international symposium on Empirical software engineering}, + pages={356--363}, + year={2006} +} + +@article{bilderbeek2020mcbette, + title={mcbette: model comparison using babette}, + author={Bilderbeek, Rich{\`e}l JC}, + journal={Journal of Open Source Software}, + volume={5}, + number={54}, + pages={2762}, + year={2020} +} + +@ARTICLE{bilderbeek2022transmembrane, + AUTHOR={Bilderbeek, Richèl J. C. and Baranov, Maksim V. and van den Bogaart, Geert and Bianchi, Frans}, + TITLE={Transmembrane Helices Are an Over-Presented and Evolutionarily Conserved Source of Major Histocompatibility Complex Class I and II Epitopes}, + JOURNAL={Frontiers in Immunology}, + VOLUME={12}, + YEAR={2022}, + URL={https://www.frontiersin.org/article/10.3389/fimmu.2021.763044}, + DOI={10.3389/fimmu.2021.763044}, + ISSN={1664-3224} +} + +@article{bonneel2020code, + title={Code replicability in computer graphics}, + author={Bonneel, Nicolas and Coeurjolly, David and Digne, Julie and Mellado, Nicolas}, + journal={ACM Transactions on Graphics (TOG)}, + volume={39}, + number={4}, + pages={93--1}, + year={2020}, + publisher={ACM New York, NY, USA} +} + +@article{bruce2009metabolic, + title={The metabolic syndrome: common origins of a multifactorial disorder}, + author={Bruce, KD and Byrne, CD}, + journal={Postgraduate medical journal}, + volume={85}, + number={1009}, + pages={614--621}, + year={2009}, + publisher={The Fellowship of Postgraduate Medicine} +} + +@article{choumert2019using, + title={Using paradata to collect better survey data: evidence from a household survey in Tanzania}, + author={Choumert-Nkolo, Johanna and Cust, Henry and Taylor, Callum}, + journal={Review of Development Economics}, + volume={23}, + number={2}, + pages={598--618}, + year={2019}, + publisher={Wiley Online Library} +} + +@article{chen2019empirical, + title={An Empirical Investigation of Correlation between Code Complexity and Bugs}, + author={Chen, Changqi}, + journal={arXiv preprint arXiv:1912.01142}, + year={2019} +} + +@article{clayton2019law, + title={The law of genetic privacy: applications, implications, and limitations}, + author={Clayton, Ellen Wright and Evans, Barbara J and Hazel, James W and Rothstein, Mark A}, + journal={Journal of Law and the Biosciences}, + volume={6}, + number={1}, + pages={1--36}, + year={2019}, + publisher={Oxford University Press} +} + +@article{conesa2019making, + title={Making multi-omics data accessible to researchers}, + author={Conesa, Ana and Beck, Stephan}, + journal={Scientific data}, + volume={6}, + number={1}, + pages={1--4}, + year={2019}, + publisher={Nature Publishing Group} +} + +@article{cosentino2017systematic, + title = "A systematic mapping study of software development with {G}it{H}ub", + author={Cosentino, Valerio and Izquierdo, Javier L C{\'a}novas and Cabot, Jordi}, + journal={IEEE Access}, + volume={5}, + pages={7173--7192}, + year={2017}, + publisher={IEEE} +} + +@article{couper1998measuring, + title={Measuring survey quality in a CASIC environment}, + author={Couper, Mick}, + journal={Proceedings of the Survey Research Methods Section of the ASA at JSM1998}, + pages={41--49}, + year={1998} +} + +@inproceedings{del1995correlation, + title={On the correlation between code coverage and software reliability}, + author={Del Frate, Fabio and Garg, Praerit and Mathur, Aditya P and Pasquini, Alberto}, + booktitle={Software Reliability Engineering, 1995. Proceedings., Sixth International Symposium on}, + pages={124--132}, + year={1995}, + organization={IEEE} +} + +@article{eklund2016cluster, + title={Cluster failure: Why fMRI inferences for spatial extent have inflated false-positive rates}, + author={Eklund, Anders and Nichols, Thomas E and Knutsson, Hans}, + journal={Proceedings of the national academy of sciences}, + volume={113}, + number={28}, + pages={7900--7905}, + year={2016}, + publisher={National Acad Sciences} +} + +@article{enroth2014strong, + title={Strong effects of genetic and lifestyle factors on biomarker variation and use of personalized cutoffs}, + author={Enroth, Stefan and Johansson, {\AA}sa and Enroth, Sofia Bosdotter and Gyllensten, Ulf}, + journal={Nature communications}, + volume={5}, + number={1}, + pages={1--11}, + year={2014}, + publisher={Nature Publishing Group} +} + +@article{erdogmus2005effectiveness, + title={On the effectiveness of the test-first approach to programming}, + author={Erdogmus, Hakan and Morisio, Maurizio and Torchiano, Marco}, + journal={IEEE Transactions on software Engineering}, + volume={31}, + number={3}, + pages={226--237}, + year={2005}, + publisher={IEEE} +} + +@inproceedings{fang2001, + title={Using a coding standard to improve program quality}, + author={Fang, Xuefen}, + booktitle={Quality Software, 2001. Proceedings. Second Asia-Pacific Conference on}, + pages={73--78}, + year={2001}, + organization={IEEE} +} + +@article{gopalakrishna2022prevalence, + title={Prevalence of questionable research practices, research misconduct and their potential explanatory factors: A survey among academic researchers in The Netherlands}, + author={Gopalakrishna, Gowri and Ter Riet, Gerben and Vink, Gerko and Stoop, Ineke and Wicherts, Jelte M and Bouter, Lex M}, + journal={PloS one}, + volume={17}, + number={2}, + pages={e0263023}, + year={2022}, + publisher={Public Library of Science} +} + +@article{gorgolewski2016practical, + title={A practical guide for improving transparency and reproducibility in neuroimaging research}, + author={Gorgolewski, Krzysztof J and Poldrack, Russell}, + journal={bioRxiv}, + pages={039354}, + year={2016}, + publisher={Cold Spring Harbor Labs Journals} +} + +@misc{glossary2003oecd, + title={The OECD glossary of statistical terms}, + author={Glossary, OECD}, + year={2003}, + publisher={Online at: http://stats.oecd.org/glossary/detail.asp} +} + +@misc{haibe2020importance, + title={The importance of transparency and reproducibility in artificial intelligence research. 2020}, + author={Haibe-Kains, Benjamin and Adam, GA and Hosny, Ahmed and Khodakarami, Farnoosh and Board, MS and Waldron, Levi and Wang, Bo and Mcintosh, Chris and Kundaje, Anshul and Greene, Casey and others}, + year={2020} +} + +@inproceedings{hata2015characteristics, + title={Characteristics of sustainable oss projects: A theoretical and empirical study}, + author={Hata, Hideaki and Todo, Taiki and Onoue, Saya and Matsumoto, Kenichi}, + booktitle={2015 IEEE/ACM 8th International Workshop on Cooperative and Human Aspects of Software Engineering}, + pages={15--21}, + year={2015}, + organization={IEEE} +} + +@article{hayes1998computing, + title={Computing Science: Bit Rot}, + author={Hayes, Brian}, + journal={American Scientist}, + volume={86}, + number={5}, + pages={410--415}, + year={1998}, + publisher={JSTOR} +} + +@article{hinsen2019dealing, + title={Dealing with software collapse}, + author={Hinsen, Konrad}, + journal={Computing in Science \& Engineering}, + volume={21}, + number={3}, + pages={104--108}, + year={2019}, + publisher={IEEE} +} + +@online{hopfner2005, + author = "Nicolas Höpfner", + title = "Wooden church of {K}aresuando, {S}weden", + year = "2005", + urlseen = "29-05-2022", + url = "https://commons.wikimedia.org/wiki/File:Karesuando_church.jpg", +} + +@article{horgan1994, + title={Achieving software quality with testing coverage measures}, + author={Horgan, Joseph R. and London, Saul and Lyu, Michael R}, + journal={Computer}, + volume={27}, + number={9}, + pages={60--69}, + year={1994}, + publisher={IEEE} +} + +@article{huvila2022improving, + title={Improving the usefulness of research data with better paradata}, + author={Huvila, Isto}, + journal={Open Information Science}, + volume={6}, + number={1}, + pages={28--48}, + year={2022}, + publisher={De Gruyter Open Access} +} + +@article{igl2010northern, + title = "The {N}orthern {S}wedish {P}opulation {H}ealth {S}tudy ({NSPHS})--a paradigmatic study in a rural population combining community health and basic research", + author={Igl, Wilmar and Johansson, {\AA}sa and Gyllensten, Ulf}, + journal={Rural and remote health}, + volume={10}, + number={2}, + pages={198--215}, + year={2010}, + publisher={James Cook University Townsville QLD.} +} + +@article{janzen2006test, + title = "Test-driven learning: intrinsic integration of testing into the {CS}/{SE} curriculum", + author={Janzen, David S and Saiedian, Hossein}, + journal={Acm Sigcse Bulletin}, + volume={38}, + number={1}, + pages={254--258}, + year={2006}, + publisher={ACM New York, NY, USA} +} + +@article{jimenez2017four, + title={Four simple recommendations to encourage best practices in research software}, + author={Jim{\'e}nez, Rafael C and Kuzak, Mateusz and Alhamdoosh, Monther and Barker, Michelle and Batut, B{\'e}r{\'e}nice and Borg, Mikael and Capella-Gutierrez, Salvador and Hong, Neil Chue and Cook, Martin and Corpas, Manuel and others}, + journal={F1000Research}, + volume={6}, + year={2017}, + publisher={Faculty of 1000 Ltd} +} + +@article{johansson2013identification, + title={Identification of genetic variants influencing the human plasma proteome}, + author={Johansson, {\AA}sa and Enroth, Stefan and Palmblad, Magnus and Deelder, Andr{\'e} M and Bergquist, Jonas and Gyllensten, Ulf}, + journal={Proceedings of the National Academy of Sciences}, + volume={110}, + number={12}, + pages={4673--4678}, + year={2013}, + publisher={National Acad Sciences} +} + +@article{Julia-2017, + title={Julia: A fresh approach to numerical computing}, + author={Bezanson, Jeff and Edelman, Alan and Karpinski, Stefan and Shah, Viral B}, + journal={SIAM {R}eview}, + volume={59}, + number={1}, + pages={65--98}, + year={2017}, + publisher={SIAM}, + doi={10.1137/141000671}, + url={https://epubs.siam.org/doi/10.1137/141000671} +} + +@article{kathiresan2012genetics, + title={Genetics of human cardiovascular disease}, + author={Kathiresan, Sekar and Srivastava, Deepak}, + journal={Cell}, + volume={148}, + number={6}, + pages={1242--1257}, + year={2012}, + publisher={Elsevier} +} + +@article{knuth1984literate, + title={Literate programming}, + author={Knuth, Donald Ervin}, + journal={The computer journal}, + volume={27}, + number={2}, + pages={97--111}, + year={1984}, + publisher={Oxford University Press} +} + +@article{labrecque2019interpretation, + title={Interpretation and potential biases of Mendelian randomization estimates with time-varying exposures}, + author={Labrecque, Jeremy A and Swanson, Sonja A}, + journal={American journal of epidemiology}, + volume={188}, + number={1}, + pages={231--238}, + year={2019}, + publisher={Oxford University Press} +} + +@article{lakos1996large, + title={Large-scale C++ software design}, + author={Lakos, John}, + journal={Reading, MA}, + volume={173}, + pages={217--271}, + year={1996} +} + +@misc{lee2018ten, + title={Ten simple rules for documenting scientific software}, + author={Lee, Benjamin D}, + journal={PLOS Computational Biology}, + volume={14}, + number={12}, + pages={e1006561}, + year={2018}, + publisher={Public Library of Science San Francisco, CA USA} +} + +@book{liberty2002sams, + title={Sams teach yourself C++ in 24 hours}, + author={Liberty, Jesse}, + year={2002}, + publisher={Sams publishing} +} + +@article{manca2018non, + title={Non-corresponding authors in the era of meta-analyses}, + author={Manca, Andrea and Cugusi, Lucia and Dvir, Zeevi and Deriu, Franca}, + journal={Journal of clinical epidemiology}, + volume={98}, + pages={159--161}, + year={2018}, + publisher={Elsevier} +} + +@misc{martin2005joint, + title={Joint Strike Fighter, Air Vehicle, C++ Coding Standard}, + author={Martin, Lockheed}, + year={2005}, + publisher={Lockheed Martin, December} +} + +@book{mcconnell2004code, + title={Code complete}, + author={McConnell, Steve}, + year={2004}, + publisher={Pearson Education} +} + +@book{meyers2005effective, + title={Effective C++: 55 specific ways to improve your programs and designs}, + author={Meyers, Scott}, + year={2005}, + publisher={Pearson Education} +} + +@book{newport2016deep, + title={Deep work: Rules for focused success in a distracted world}, + author={Newport, Cal}, + year={2016}, + publisher={Hachette UK} +} + +@article{nicolaas2011survey, + title={Survey paradata: a review}, + author={Nicolaas, Gerry}, + year={2011}, + publisher={NCRM} +} + +@article{o2003email, + title = "Is email a reliable means of contacting authors of previously published papers? {A} study of the {E}mergency {M}edicine {J}ournal for 2001", + author={O’Leary, F}, + journal={Emergency medicine journal}, + volume={20}, + number={4}, + pages={352--353}, + year={2003}, + publisher={British Association for Accident and Emergency Medicine} +} + +@article{obels2020analysis, + title={Analysis of open data and computational reproducibility in registered reports in psychology}, + author={Obels, Pepijn and Lakens, Daniel and Coles, Nicholas A and Gottfried, Jaroslav and Green, Seth A}, + journal={Advances in Methods and Practices in Psychological Science}, + volume={3}, + number={2}, + pages={229--237}, + year={2020}, + publisher={Sage Publications Sage CA: Los Angeles, CA} +} + +@article{patil2019visual, + title={A visual tool for defining reproducibility and replicability}, + author={Patil, Prasad and Peng, Roger D and Leek, Jeffrey T}, + journal={Nature human behaviour}, + volume={3}, + number={7}, + pages={650--652}, + year={2019}, + publisher={Nature Publishing Group} +} + +@article{peng2006reproducible, + title={Reproducible epidemiologic research}, + author={Peng, Roger D and Dominici, Francesca and Zeger, Scott L}, + journal={American journal of epidemiology}, + volume={163}, + number={9}, + pages={783--789}, + year={2006}, + publisher={Oxford University Press} +} + +@article{peng2011reproducible, + title={Reproducible research in computational science}, + author={Peng, Roger D}, + journal={Science}, + volume={334}, + number={6060}, + pages={1226--1227}, + year={2011}, + publisher={American Association for the Advancement of Science} +} + +@article{peng2021reproducible, + title={Reproducible research: A retrospective}, + author={Peng, Roger D and Hicks, Stephanie C}, + journal={Annual review of public health}, + volume={42}, + pages={79--93}, + year={2021}, + publisher={Annual Reviews} +} + +@article{perez2016ten, + title = "Ten Simple Rules for Taking Advantage of git and {G}it{H}ub", + author={Perez-Riverol, Yasset and Gatto, Laurent and Wang, Rui and Sachsenberg, Timo and Uszkoreit, Julian and Leprevost, Felipe and Fufezan, Christian and Ternent, Tobias and Eglen, Stephen J and Katz, Daniel SS and others}, + journal={bioRxiv}, + pages={048744}, + year={2016}, + publisher={Cold Spring Harbor Labs Journals} +} + +@article{pianosi2020successfully, + title = "How successfully is open-source research software adopted? {R}esults and implications of surveying the users of a sensitivity analysis toolbox", + author={Pianosi, Francesca and Sarrazin, Fanny and Wagener, Thorsten}, + journal={Environmental Modelling \& Software}, + volume={124}, + pages={104579}, + year={2020}, + publisher={Elsevier} +} + +@article{pope2003will, + title = "Will a healthy lifestyle help prevent {A}lzheimer's disease?", + author={Pope, Sandra K and Shue, Valorie M and Beck, Cornelia}, + journal={Annual review of public health}, + volume={24}, + number={1}, + pages={111--132}, + year={2003}, + publisher={Annual Reviews 4139 El Camino Way, PO Box 10139, Palo Alto, CA 94303-0139, USA} +} + +@article{prive2020ldpred2, + title={LDpred2: better, faster, stronger}, + author={Priv{\'e}, Florian and Arbel, Julyan and Vilhj{\'a}lmsson, Bjarni J}, + journal={Bioinformatics}, + volume={36}, + number={22-23}, + pages={5424--5431}, + year={2020}, + publisher={Oxford University Press} +} + +@Manual{r, + title = {R: A Language and Environment for Statistical Computing}, + author = {{R Core Team}}, + organization = {R Foundation for Statistical Computing}, + address = {Vienna, Austria}, + year = {2021}, + url = {https://www.R-project.org/}, +} + +@article{rahman2020exploratory, + title={An exploratory characterization of bugs in covid-19 software projects}, + author={Rahman, Akond and Farhana, Effat}, + journal={arXiv preprint arXiv:2006.00586}, + year={2020} +} + +@inproceedings{ram2013ropensci, + title = "{rOpenSci}-open tools for open science", + author={Ram, K}, + booktitle={AGU Fall Meeting Abstracts}, + volume={2013}, + pages={ED43E--04}, + year={2013} +} + +@article{ram2018community, + title={A community of practice around peer review for long-term research software sustainability}, + author={Ram, Karthik and Boettiger, Carl and Chamberlain, Scott and Ross, Noam and Salmon, Ma{\"e}lle and Butland, Stefanie}, + journal={Computing in Science \& Engineering}, + volume={21}, + number={2}, + pages={59--65}, + year={2018}, + publisher={IEEE} +} + +@article{read2015sizing, + title = "Sizing the problem of improving discovery and access to {NIH}-funded data: a preliminary study", + author={Read, Kevin B and Sheehan, Jerry R and Huerta, Michael F and Knecht, Lou S and Mork, James G and Humphreys, Betsy L and NIH Big Data Annotator Group}, + journal={PLoS One}, + volume={10}, + number={7}, + pages={e0132735}, + year={2015}, + publisher={Public Library of Science San Francisco, CA USA} +} + +@inproceedings{reenskaug1989environment, + title = "An environment for literate {S}malltalk programming", + author={Reenskaug, Trygve and Skaar, Anna Lise}, + booktitle={Conference proceedings on Object-oriented programming systems, languages and applications}, + pages={337--345}, + year={1989} +} + +@software{ropensci_2021_6619350, + author = {rOpenSci and + Anderson, Brooke and + Chamberlain, Scott and + DeCicco, Laura and + Gustavsen, Julia and + Krystalli, Anna and + Lepore, Mauro and + Mullen, Lincoln and + Ram, Karthik and + Ross, Noam and + Salmon, Maëlle and + Vidoni, Melina and + Riederer, Emily and + Sparks, Adam and + Hollister, Jeff}, + title = {{rOpenSci Packages: Development, Maintenance, and + Peer Review}}, + month = nov, + year = 2021, + publisher = {Zenodo}, + version = {0.7.0}, + doi = {10.5281/zenodo.6619350}, + url = {https://doi.org/10.5281/zenodo.6619350} +} +@article{russell2018large, + title = "A large-scale analysis of bioinformatics code on {G}it{H}ub", + author={Russell, Pamela H and Johnson, Rachel L and Ananthan, Shreyas and Harnke, Benjamin and Carlson, Nichole E}, + journal={PLoS One}, + volume={13}, + number={10}, + pages={e0205898}, + year={2018}, + publisher={Public Library of Science San Francisco, CA USA} +} + +@inproceedings{sadowski2018modern, + title = "Modern code review: a case study at {G}oogle", + author={Sadowski, Caitlin and S{\"o}derberg, Emma and Church, Luke and Sipko, Michal and Bacchelli, Alberto}, + booktitle={Proceedings of the 40th International Conference on Software Engineering: Software Engineering in Practice}, + pages={181--190}, + year={2018} +} + +@inproceedings{shmerlin2015document, + title={To document or not to document? An exploratory study on developers’ motivation to document code}, + author={Shmerlin, Yulia and Hadar, Irit and Kliger, Doron and Makabee, Hayim}, + booktitle={Advanced Information Systems Engineering Workshops: CAiSE 2015 International Workshops, Stockholm, Sweden, June 8-9, 2015, Proceedings 27}, + pages={100--106}, + year={2015}, + organization={Springer} +} + +@online{shafee2015, + author = "Thomas Shafee", + title = "Protein coding genes are transcribed to an {mRNA} intermediate, then translated to a functional protein. {RNA}-coding genes are transcribed to a functional non-coding {RNA}", + year = "2005", + urlseen = "29-05-2022", + url = "https://en.wikipedia.org/wiki/File:DNA_to_protein_or_ncRNA.svg", +} + +@article{skold2022interrogating, + title={Interrogating paradata}, + author={Sk{\"o}ld, Olle and B{\"o}rjesson, Lisa and Huvila, Isto}, + year={2022}, + publisher={University of Bor{\aa}s} +} + +@online{sponk2012, + author = "Sponk and Tryphon and Magnus Manske and User:Dietzel65 and LadyofHats (Mariana Ruiz) and Radio89", + title = "Diagram of {DNA} in a eukaryotic cell", + year = "2012", + urlseen = "29-05-2022", + url = "https://commons.wikimedia.org/wiki/File:Eukaryote_DNA-en.svg", +} + +@book{steele1983hacker, + title={The hacker's dictionary: a guide to the world of computer wizards}, + author={Steele Jr, Guy L and Woods, Donald R and Finkel, Raphael R and Stallman, Richard M and Goodfellow, Geoffrey S}, + year={1983}, + publisher={Harper \& Row Publishers, Inc.} +} + +@article{stodden2011trust, + title = "Trust your science? {O}pen your data and code", + author={Stodden, Victoria C}, + year={2011} +} + +@article{stodden2013best, + title={Best practices for computational science: Software infrastructure and environments for reproducible and extensible research}, + author={Stodden, Victoria and Miguez, Sheila}, + journal={Available at SSRN 2322276}, + year={2013} +} + +@article{stodden2018empirical, + title={An empirical analysis of journal policy effectiveness for computational reproducibility}, + author={Stodden, Victoria and Seiler, Jennifer and Ma, Zhaokun}, + journal={Proceedings of the National Academy of Sciences}, + volume={115}, + number={11}, + pages={2584--2589}, + year={2018}, + publisher={National Acad Sciences} +} + +@article{storhaug2017country, + title={Country, regional, and global estimates for lactose malabsorption in adults: a systematic review and meta-analysis}, + author={Storhaug, Christian L{\o}vold and Fosse, Svein Kjetil and Fadnes, Lars T}, + journal={The Lancet Gastroenterology \& Hepatology}, + volume={2}, + number={10}, + pages={738--746}, + year={2017}, + publisher={Elsevier} +} + +@book{stroustrup2013cpp, + title={The C++ programming language}, + author={Stroustrup, Bjarne}, + year={2013}, + publisher={Pearson Education} +} + +@article{stroustrup2018cpp, + title={C++ core guidelines}, + author={Stroustrup, Bjarne and Sutter, Herb and others}, + journal={Web. Last accessed February}, + year={2018} +} + +@book{sutter2004cpp, + title={C++ coding standards: 101 rules, guidelines, and best practices}, + author={Sutter, Herb and Alexandrescu, Andrei}, + year={2004}, + publisher={Pearson Education} +} + +@article{vable2021code, + title={Code review as a simple trick to enhance reproducibility, accelerate learning, and improve the quality of your team’s research}, + author={Vable, Anusha M and Diehl, Scott F and Glymour, M Maria}, + journal={American Journal of Epidemiology}, + volume={190}, + number={10}, + pages={2172--2177}, + year={2021}, + publisher={Oxford University Press} +} + +@book{van1995python, + title={Python tutorial}, + author={Van Rossum, Guido and Drake Jr, Fred L}, + volume={620}, + year={1995}, + publisher={Centrum voor Wiskunde en Informatica Amsterdam, The Netherlands} +} + +@article{van2001pep, + title = "{PEP} 8--style guide for {P}ython code", + author={Van Rossum, Guido and Warsaw, Barry and Coghlan, Nick}, + journal={Python. org}, + volume={1565}, + year={2001} +} + +@inproceedings{vasilescu2015, + title = "Quality and productivity outcomes relating to continuous integration in {G}it{H}ub", + author={Vasilescu, Bogdan and Yu, Yue and Wang, Huaimin and Devanbu, Premkumar and Filkov, Vladimir}, + booktitle={Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering}, + pages={805--816}, + year={2015}, + organization={ACM} +} + +@inproceedings{wang2020assessing, + title = "Assessing and restoring reproducibility of {J}upyter notebooks", + author={Wang, Jiawei and Kuo, Tzu-yang and Li, Li and Zeller, Andreas}, + booktitle={Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering}, + pages={138--149}, + year={2020} +} + +@article{weissgerber2018we, + title = "Why we need to report more than'{D}ata were analyzed by t-tests or {ANOVA}'", + author={Weissgerber, Tracey L and Garcia-Valencia, Oscar and Garovic, Vesna D and Milic, Natasa M and Winham, Stacey J}, + journal={Elife}, + volume={7}, + pages={e36163}, + year={2018}, + publisher={eLife Sciences Publications, Ltd} +} + +@article{wicherts2016degrees, + title={Degrees of freedom in planning, running, analyzing, and reporting psychological studies: A checklist to avoid p-hacking}, + author={Wicherts, Jelte M and Veldkamp, Coosje LS and Augusteijn, Hilde EM and Bakker, Marjan and Van Aert, Robbie and Van Assen, Marcel ALM}, + journal={Frontiers in psychology}, + pages={1832}, + year={2016}, + publisher={Frontiers} +} + +@book{wickham2015r, + title={R packages: organize, test, document, and share your code}, + author={Wickham, Hadley}, + year={2015}, + publisher={" O'Reilly Media, Inc."} +} + +@book{wickham2019advanced, + title = "Advanced {R}", + author={Wickham, Hadley}, + year={2019}, + publisher={CRC press} +} + +@article{wilson2014best, + title={Best practices for scientific computing}, + author={Wilson, Greg and Aruliah, Dhavide A and Brown, C Titus and Hong, Neil P Chue and Davis, Matt and Guy, Richard T and Haddock, Steven HD and Huff, Kathryn D and Mitchell, Ian M and Plumbley, Mark D and others}, + journal={PLoS biology}, + volume={12}, + number={1}, + pages={e1001745}, + year={2014}, + publisher={Public Library of Science} +} + +@article{wilson2022twelve, + title={Twelve quick tips for software design}, + author={Wilson, Greg}, + journal={PLoS Computational Biology}, + volume={18}, + number={2}, + pages={e1009809}, + year={2022}, + publisher={Public Library of Science San Francisco, CA USA} +} + +@article{wilkinson2016fair, + title = "The {FAIR} {G}uiding {P}rinciples for scientific data management and stewardship", + author={Wilkinson, Mark D and Dumontier, Michel and Aalbersberg, IJsbrand Jan and Appleton, Gabrielle and Axton, Myles and Baak, Arie and Blomberg, Niklas and Boiten, Jan-Willem and da Silva Santos, Luiz Bonino and Bourne, Philip E and others}, + journal={Scientific data}, + volume={3}, + number={1}, + pages={1--9}, + year={2016}, + publisher={Nature Publishing Group} +} + +@inproceedings{zhang2016review, + title={A review of homomorphic encryption and its applications}, + author={Zhang, Lifang and Zheng, Yan and Kantoa, Raimo}, + booktitle={Proceedings of the 9th EAI International Conference on Mobile Multimedia Communications}, + pages={97--106}, + year={2016} +} + +@incollection{zimmermann2008predicting, + title={Predicting bugs from history}, + author={Zimmermann, Thomas and Nagappan, Nachiappan and Zeller, Andreas}, + booktitle={Software evolution}, + pages={69--88}, + year={2008}, + publisher={Springer} +} + diff --git a/lesson_plans/day_5/day_5.qmd b/lesson_plans/day_5/day_5.qmd new file mode 100644 index 0000000..86e5802 --- /dev/null +++ b/lesson_plans/day_5/day_5.qmd @@ -0,0 +1,994 @@ +--- +title: "Day 5" +author: "Richèl Bilderbeek" +format: revealjs +bibliography: day_5.bib +from: markdown+emoji +csl: vancouver.csl +jupyter: python3 +css: styles.css +slide-number: true +number-sections: true +--- + +# Big Picture + +## Breaks + +Please take breaks: +these are important for learning. +Ideally, do something boring @newport2016deep! + +## Break schedule + + * 10:00-10:15 + * 11:00-11:15 + * 12:00-13:00 + * 14:00-14:15 + * 15:00-15:15 + * 16:00-16:15 + +## Question + +What is mastery in programming? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## My answer + +To be able to express your ideas in correct and readable code +in an elegant way. + +# Express your assumptions in code + +## Problem + +```{python} +#| eval: false +#| echo: true +numerator = # something +denominator = # something +# denominator is not zero +value = numerator / denominator +``` + +How to do better? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Naive answer + +```{python} +#| eval: true +#| echo: true +numerator = 1.2 +denominator = 3.4 +# denominator is not zero +if denominator == 0.0: + print("ERROR! QUIT!") +``` + +What do we express here? + +## `assert` + +Express: 'I believe this to be true': + +```{python} +#| echo: true +#| eval: true +assert 1 + 1 == 2 +``` + +This presentation will not compile when an `assert` fails! + +## `assert` in action + +```{python} +#| echo: true +#| eval: true +numerator = 1.2 +denominator = 3.4 +assert denominator != 0.0 +value = numerator / denominator +``` + +Use assert extensively @sutter2004cpp@stroustrup2013cpp@mcconnell2004code +@liberty2002sams@lakos1996large. + +## `assert` references 1/2 + + * @sutter2004cpp Chapter 68: ' + Assert liberally to document internal assumptions and invariants' + * @stroustrup2013cpp (3rd edition) Advice 24.5.18: + 'Explicitly express preconditions, postconditions, + and other assertions as assertions' + * @mcconnell2004code Chapter 8.2: + 'Use assertions to document and verify preconditions and postconditions' + * @mcconnell2004code Chapter 8.2: + 'Use assertions for conditions that should never occur'. + * @liberty2002sams Chapter 'assert()': 'Use assert freely' + +## `assert` references 2/2 + + * @lakos1996large Chapter 2.6: + 'The use of assert statements can help to document the assumptions + you make when implementing your code + * @stroustrup2018cpp (4th edition) page 884: + '[13] Use static_assert() and assert() extensively' + +## Questions about `assert`? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Express yourself in readable code + +## Problem + +```{python} +#| echo: true +#| eval: true +a = 3 +b = 4 +# Calculate the Euclidean distance +# using Pythagoras' theorem +c = ((a * a) + (b * b)) ** 0.5 +``` + +How to express ourselves in code? How to do better? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Solution + +```{python} +#| echo: false +#| eval: true +def calc_euclidian_distance(a, b): + return ((a * a) + (b * b)) ** 0.5 +``` + +```{python} +#| echo: true +#| eval: true +a = 3 +b = 4 +c = calc_euclidian_distance(a, b) +``` + +We use a function! + +## Question about functions + + * What is a function? + * What makes a good function? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## My answer + +A function is a unit of code, that has a name, optional inputs +and optional output. + +![](function_cartoon.png) + +## About good functions 1/3 + + * @meyers2005effective Item 18: + 'Make interfaces easy to use correctly and hard to use incorrectly.' + * @sutter2004cpp Item 20: 'Avoid long functions. Avoid deep nesting' + * @stroustrup2013cpp (4th edition) page 341: + '[1] Package meaningful operations as carefully named functions' + * @stroustrup2013cpp (4th edition) page 341: + '[2] A function should perform a single logical operation' + * @stroustrup2013cpp (4th edition) page 341: + '[3] Keep functions short' + +## About good functions 2/3 + + * @lakos1996large Chapter 2.6: + Document the interfaces so that they are usable by others. + Have at least one other developer review each interface + * @martin2005joint AV Rule 1: 'Any one function (or method) + will contain no more than 200 logical source lines of code.' + +## About good functions 3/3 + + * @stroustrup2013cpp (4th edition) page 341: '[20] Specify preconditions and + postconditions for your functions' + * @stroustrup2018cpp I.5: State preconditions (if any) + * @stroustrup2018cpp I.7: State postconditions + * @stroustrup2018cpp I.1: Make interfaces explicit + * @stroustrup2018cpp I.4: Make interfaces precisely and strongly typed + +## Function parts by importance + + 1. The name + 2. The tests + 3. The documentation + 4. The body + +Your boss will rarely care about the body of your functions. + +## Questions about functions? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Making your code readable + +## Function name + +The **name** is the most important part of a function. + + * A good name makes it natural to use the function correctly. + * A bad name confuses the reader. + +## Function name + +> There are only two hard things in Computer Science: +> cache invalidation and naming things. +> +> Phil Karlton + +## Function name conventions + + * Starts with a verb + * All letters lowercase @van2001pep + * All words separated by underscores @van2001pep + * Common verbs abbreviations are allowed + +```{python} +#| echo: true +#| eval: false +print_hello_world() +``` + +## Questions 1 + +Give the Python function name to determine if something ... + + * is zero + * is bigger than zero + * is a number + * is a empty list + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answers 1 + + * is zero: `is_zero` + * is bigger than zero: `is_positive`, `is_bigger_than_zero` + * is a number: `is_number` + * is a empty list: `is_empty_list` + +## Questions 2 + +Give the Python function name to determine if something ... + + * is a list of strings + * is a list of integers + * is a list of integers of only zeroes + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answers 2 + + * is a list of strings: `is_string_list`, `is_text`, `are_strings` + * is a list of integers: `is_integer_list`, `are_integers`, `are_ints` + * is a list of integers of only zeroes: `are_zeroes` + +## Exercise + + * Fill in the blanks + * Multiple answers are correct + +## Question 3 + +```{python} +#| echo: true +#| eval: false +def ___(number): + return number == 0.0 + +assert ___(0.0) +assert not ___(3.14) +``` + +## Answer 3 + +```{python} +#| echo: true +#| eval: true +def is_zero(number): + return number == 0.0 + +assert is_zero(0.0) +assert not is_zero(3.14) +``` + +## Question 4 + +```{python} +#| echo: true +#| eval: false +def ____(number): + return number > 0.0 + +assert ___(1.0) +assert not ___(0.0) +assert not ___(-1.0) +``` + +## Answer 4 + +```{python} +#| echo: true +#| eval: true +def is_bigger_than_zero(number): + return number > 0.0 + +assert is_bigger_than_zero(1.0) +assert not is_bigger_than_zero(0.0) +assert not is_bigger_than_zero(-1.0) +``` + +## Question 5 + +```{python} +#| echo: true +#| eval: false +def ___(my_list): + return len(my_list) == 0 + +assert ___([]) +assert not ___([1]) +assert not ___([1, 2]) +``` + +## Answer 5 + +```{python} +#| echo: true +#| eval: true +def is_empty_list(my_list): + return len(my_list) == 0 + +assert is_empty_list([]) +assert not is_empty_list([1]) +assert not is_empty_list([1, 2]) +``` + +## Question 6 + +```{python} +#| echo: true +#| eval: false +def ___(my_list): + return sum(my_list) + +assert ___([1]) == 1 +assert ___([1, 2]) == 3 +assert ___([1, 2, 3]) == 6 +``` + +## Answer 6 + +```{python} +#| echo: true +#| eval: true +def calc_sum(my_list): + return sum(my_list) + +# assert calc_sum([]) == 0 +assert calc_sum([1]) == 1 +assert calc_sum([1, 2]) == 3 +assert calc_sum([1, 2, 3]) == 6 +``` + +## Question 7 + +```{python} +#| echo: true +#| eval: false +def ___(my_list): + return sorted(my_list) + +assert ___([2, 1]) == [1, 2] +assert ___([3, 2, 1]) == [1, 2, 3] +``` + +## Answer 7 + +```{python} +#| echo: true +#| eval: true +def create_sorted_list(my_list): + return sorted(my_list) + +assert create_sorted_list([2, 1]) \ + == [1, 2] +assert create_sorted_list([3, 2, 1]) \ + == [1, 2, 3] +``` + + +## Question 8 + +```{python} +#| echo: true +#| eval: false +def ___(my_list): + // Bonus: assert __ + return sum(my_list) / len(my_list) + +assert ___([1, 3]) == 2 +assert ___([1, 3, 5]) == 3 +``` + +## Answer 8 + +```{python} +#| echo: true +#| eval: true +def calculate_mean(my_list): + assert len(my_list) + return sum(my_list) / len(my_list) + +assert calculate_mean([1, 3]) == 2 +assert calculate_mean([1, 3, 5]) == 3 +``` + +## Questions about function names? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Do work in the right order + +## We were all kids once + +**Imagine** you need to write a function, for example, +to determine if a number is prime. +**Remember** when you just started programming: +what were your first lines of code? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Your first code + +```{python} +#| echo: true +#| eval: false +def prime(number) + for i in range(1, number) + for j in range(2, i) + if i %% j: +``` + +What is the problem of writing this part first? + + * Do not fix the code! + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Next answer + +We overload our working memory. +We do too many things. +Instead, work from big to small: +write the tests first! + +## Test-Driven Development + +Writing test first is a software methodology, called +Test-Driven Development. + +## Effects of TDD + +Test-Driven Development ... + + * makes developers more productive @erdogmus2005effectiveness + * increases quality of the code + @erdogmus2005effectiveness @alkaoud2018quality @janzen2006test + * There are plenty of costly programming mistakes documented! + * helps shape the project architecture @mayr2005projekt + * helps better modularisation @madeyski2010test + * works great with Xtreme programming and CI + +## For us + +We 'only' use tests to express what we expect our function to do. + +## Example question + +```{python} +#| echo: true +#| eval: false +def is_float(number): + # Google this! + +assert is_float(3.14) +assert not is_float(42) +assert not is_float('Hello') +assert not is_float([1.2, 3.4]) +assert not is_float((1.2, 3.4)) +``` + +## Example answer + +```{python} +#| echo: true +#| eval: true +def is_float(number): + return isinstance(number, float) + +assert is_float(3.14) +assert not is_float(42) +assert not is_float('Hello') +assert not is_float([1.2, 3.4]) +assert not is_float((1.2, 3.4)) +``` + +## Question 1 + +Write the tests for a function to determine if a file exists. + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 1 + +```{python} +#| echo: false +#| eval: true +def does_file_exist(filename): + return filename == "day_3.qml" +``` + +```{python} +#| echo: true +#| eval: true +assert does_file_exist("day_3.qml") +assert not does_file_exist("abs.ent") +``` + +## Question 2 + +Write the tests for a function to read the content of a file +into a list of strings. + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 2 + +```{python} +#| echo: true +#| eval: false + +assert len(read_file("my.txt")) +assert is_string(read_file("my.txt")[0]) +assert is_text(read_file("my.txt")) +``` + +'a list of string' can be called 'text' :-) + +## Question 3 + +Write the tests for a function to read the content of a file +into a list of strings, yet skipping the first line + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 3 + +```{python} +#| echo: true +#| eval: false +# Save space +f = read_file_without_header + +assert len(f("day_3.qml")) +assert is_string(f("day_3.qml")[0]) +assert is_text(f("day_3.qml")) +assert len(f("day_3.qml")) \ + == len(read_file("day_3.qml")) - 1 +``` + +## Question 4 + +Imagine a function called `create_test_table` that returns the text below as a list of strings. +Write its tests. + +```{python} +#| echo: true +#| eval: false +First name|Last name +Alita |Colbert +Brandi |Lovell +Corrina |Georgeanna +``` + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 4 + +```{python} +#| echo: true +#| eval: false +# Save space +f = create_test_table + +assert len(f()) == 4 +assert f()[0] == "First name|Last name" +assert f()[1] == "Alita |Colbert" +assert f()[2] == "Brandi |Lovell" +assert f()[3] == "Corrina |Georgeanna" +``` + +## Question 5 + +Assume a table as text, including headers. +Extract the `n`th column as a list of strings. +Use `create_test_table` in your tests + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 5 + +```{python} +#| echo: true +#| eval: false +# Save space +f = get_nth_column + +table = create_test_table() + +# A column has no header +n_rows = len(table) +first_column = f(table, 0) +n_elements = len(first_column) +assert(n_rows - 1 == n_elements) + +assert f(table, 0)[0] == "Alita" +assert f(table, 0)[1] == "Brandi" +assert f(table, 0)[2] == "Corrina" +assert f(table, 1)[0] == "Colbert" +assert f(table, 1)[1] == "Lovell" +assert f(table, 1)[2] == "Georgeanna" +``` + +## Question 6 + +Split a string into its elements. +The elements are separated by commas, e.g. `"A,B,C"`. +Remove the whitespace at the edges. + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer 6 + +```{python} +#| echo: true +#| eval: false +assert split_str("A") == ["A"] +assert split_str("A,B") == ["A", "B"] +assert split_str("A,B ") == ["A", "B"] +assert split_str(" A,B ") == ["A", "B"] +assert split_str("A ,B ") == ["A", "B"] +assert split_str("A, B ") == ["A", "B"] +``` + +## Questions about function testing? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Make your function usable by others + +## Adding documentation + +```{python} +#| echo: true +#| eval: true +def split_str(x): + """ + Split 'x' into its comma-seperated + parts. + Assumes 'x' is a string + of at least 1 character; + will terminate the program + if not + """ + # Do it +``` + +## Questions about function documentation? + +:woman_technologist: Write down in the HackMD! :man_technologist: + + * More on this tomorrow + +# Writing the function body + +## Question + +When is a function body good enough? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Writing a good function body + +If all test pass, it is good. Done! + +## Speed? + +> Premature optimization is the root of all evil. +> +> Donald Knuth + +## Questions about writing a function body? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Exercise + +Do + + * `Day 3` -> `Exercise 1 - functions` + * `Day 3` -> `PyQuiz 3.2` + +# Expressing a set + +## Question + +What is set? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer + +'A collection things' + +For example, the ages of people in a room: + +```{python} +#| echo: true +#| eval: false +ages = [] +ages = [8] +ages = [8] +ages = [8, 18] +``` + +## Question + +Write the **tests** for a function +to add values to a list **only** when a value +is not present yet. + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer + +```{python} +#| echo: true +#| eval: false +f = add_value_to_set +ages = [] +ages = f(ages, 8) +ages = f(ages, 8) +ages = f(ages, 18) +assert ages == [8, 18] +``` + +## Question + +Would it be possible to express this better? How? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer + +One can use a Python set. + +```{python} +#| echo: true +#| eval: false +ages = {} +ages.add(8) +ages.add(8) +ages.add(18) +assert ages == {8, 18} +assert ages == [8, 18] +``` + +## Reflection + +Classes ... + + * can be built-in, e.g. string, lists and sets + * have a clear purpose + * allow us to express ourselves **elegantly** + * help us to **maintain overview**, + e.g. we know things about elements in a set + +## Questions about sets? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Expressing a dictionary + +## Trick question + +Write the tests for some functions +to work with a telephone book. + +One function allows to add a name and phone number. +If the name already exists, overwrite the phone number. + +## Naive answer + +```{python} +#| echo: true +#| eval: false +# To save space +p = create_phone_book() +p = add(p, "Aardvark", 1234567890) +p = add(p, "Zziiz", 1234567891) +assert get_phone_number( \ + p, "Aardvark") \ + == 1234567890 +``` + +This will be a *tour de force*! + +## Better answer + +Use a dictionary! + +```{python} +#| echo: true +#| eval: true +# To save space +p = { \ + "Aardvark": 1234567890, \ + "Zziiz": 1234567891 \ + } +assert p["Aardvark"] == 1234567890 +p["Zziiz"] = 9876543210 +assert p["Zziiz"] == 9876543210 +``` + +## Questions about dictionaries? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Exercise + +Do + + * `Day 3` -> `IMDb exercise - Day 3` + * `Day 3` -> `PyQuiz 3.1` + +# Using system arguments + +## Problem + +Imagine you have written a useful Python script. +You want to run the script in two different ways: + + * Quiet: no output + * Verbose: with many prints to the screen + +How to do this? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Answer + +**Call** the script differently, for example: + +```{python} +#| echo: true +#| eval: false +python3 my_script.py --verbose +python3 my_script.py --quiet +``` + +## Exercise, little help + +Write a Python script that ... + + * when run with `--verbose` states it is running verbosely + * when run with `--quiet` (ironically) states it is running quietly + +Either Google or read the next slide for hints + +:woman_technologist: Write down in the HackMD! :man_technologist: + +## Exercise, more help + +```{python} +#| echo: true +#| eval: false +import sys + +print(sys.argv) +``` + +`sys.argv` is a list of strings. + +## Answer + +```{python} +#| echo: true +#| eval: false +import sys + +assert len(sys.argv) == 2 +if sys.argv[1] == "--quiet": + print("Quiet") +elif sys.argv[1] == "--verbose": + print("Verbose!") +else: + print("ERROR! Unknown argument!") +``` + +## Questions about command line arguments? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +# Conclusion + +> To be able to express your ideas in correct and readable code +> in an elegant way. + + * Express assumptions with `assert`s + * Use functions to make code readable + * Use tests to verify the code is correct + * Use sets or dictionaries when this fits naturally + +## Questions about today's theory? + +:woman_technologist: Write down in the HackMD! :man_technologist: + +If not, apply this in The Project: + + * Use `assert` + * Split code into functions + * Test functions + +# Done! + +Go home and rest :-) + +# Breaks + +Are important. Please rest! + +## Break 1: 10:00-10:15 + +![](forgetting.png) + +## Break 2: 11:00-11:15 + +![](dilbert_tdd.png) + +## Break 3: 12:00-13:00 + +![](dilbert_agile_1.png) + +## Break 4: 14:00-14:15 + +![](dilbert_agile_2.png) + +## Break 5: 15:00-15:15 + +![](dilbert_tdd_2.png) + +## Break 6: 16:00-16:15 + +![](dilbert_tdd_3.png) + +## Done + +![](dilbert_tdd_4.png) + +## References diff --git a/lesson_plans/day_5/day_5_schedule_reminder.sh b/lesson_plans/day_5/day_5_schedule_reminder.sh new file mode 100755 index 0000000..f970d5d --- /dev/null +++ b/lesson_plans/day_5/day_5_schedule_reminder.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo 'espeak -s 120 -p 10 "start to work"' | at 9:00 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 10:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 10:15 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 11:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 11:15 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 12:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 13:00 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 14:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 14:15 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 15:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 15:15 +echo 'espeak -s 120 -p 10 "time to have a break"' | at 16:00 +echo 'espeak -s 120 -p 10 "back to work"' | at 16:15 +echo 'espeak -s 120 -p 10 "enjoy the rest of your day"' | at 17:00 diff --git a/lesson_plans/day_5/render.sh b/lesson_plans/day_5/render.sh new file mode 100755 index 0000000..9b82282 --- /dev/null +++ b/lesson_plans/day_5/render.sh @@ -0,0 +1,3 @@ +#!/bin/bash +quarto render day_3.qmd --to html +quarto render day_3.qmd --to pdf --toc diff --git a/lesson_plans/day_5/styles.css b/lesson_plans/day_5/styles.css new file mode 100644 index 0000000..d4b0ed6 --- /dev/null +++ b/lesson_plans/day_5/styles.css @@ -0,0 +1,7 @@ +.reveal section p { + font-size: 1.75em; +} + +.reveal section pre code { + font-size: 1.75em; +} diff --git a/lesson_plans/day_5/tdd_cycle_2.jpg b/lesson_plans/day_5/tdd_cycle_2.jpg new file mode 100644 index 0000000..dd89fa8 Binary files /dev/null and b/lesson_plans/day_5/tdd_cycle_2.jpg differ diff --git a/lesson_plans/day_5/tdd_hat_1.jpg b/lesson_plans/day_5/tdd_hat_1.jpg new file mode 100644 index 0000000..dca1c07 Binary files /dev/null and b/lesson_plans/day_5/tdd_hat_1.jpg differ diff --git a/lesson_plans/day_5/tdd_hat_2.jpg b/lesson_plans/day_5/tdd_hat_2.jpg new file mode 100644 index 0000000..b905ef4 Binary files /dev/null and b/lesson_plans/day_5/tdd_hat_2.jpg differ diff --git a/lesson_plans/day_5/test.sh b/lesson_plans/day_5/test.sh new file mode 100755 index 0000000..a058c6e --- /dev/null +++ b/lesson_plans/day_5/test.sh @@ -0,0 +1,2 @@ +#!/bin/bash +while true; do espeak "test"; sleep 1; done diff --git a/lesson_plans/day_5/vancouver.csl b/lesson_plans/day_5/vancouver.csl new file mode 100644 index 0000000..e39efa8 --- /dev/null +++ b/lesson_plans/day_5/vancouver.csl @@ -0,0 +1,351 @@ + +