Skip to content
Snippets Groups Projects
Commit e420df07 authored by Theresa Mieslinger's avatar Theresa Mieslinger
Browse files

change structure and follow Bjorn's idea of this lecture

parent b6bed06b
No related branches found
No related tags found
1 merge request!57First draft for Good Scientific and Coding Practice
Pipeline #72398 passed
...@@ -3,65 +3,96 @@ title: "Good scientific and coding practice" ...@@ -3,65 +3,96 @@ title: "Good scientific and coding practice"
author: "Bjorn Stevens and Theresa Mieslinger" author: "Bjorn Stevens and Theresa Mieslinger"
--- ---
# Good coding practice # Good Scientific Practice
***consistency is the key*** *Building trust in research. And in your own work.*
* clean code ## What is it and why should we care?
* efficient code * Principles fomulated by the research community that define proper research behaviour with the aim to ensure a high quality, robustness and reproducibility of results (publications, data, code, software).
* understandable code * How it relates to this course: it provides rules for building software, using own and other software/data and for communicate the usage of software/data.
* tracable code changes
## The pillars of Good Scientific Practice
::: {.incremental}
* **Reliability** in ensuring the quality of research, reflected in the design, methodology, analysis, and use of resources.
* **Honesty** in developing, undertaking, reviewing, reporting, and communicating research in a transparent, fair, full, and unbiased way.
* **Respect** for colleagues, research participants, research subjects, society, ecosystems, cultural heritage, and the environment.
* **Accountability** for the research from idea to publication, for its management and organisation, for training, supervision, and mentoring, and for its wider societal impacts.
:::
*copied from [European Code of Conduct for Research Integrity](https://allea.org/wp-content/uploads/2023/06/European-Code-of-Conduct-Revised-Edition-2023.pdf)*
## Style Guides ## The pillars of Good Scientific Practice
***code is read much more often than it is written***
Each programing language has it's own guidlines: * Reliability / **Reproducibility**
* primary data
* data management and sharing
* Honesty
* **Respect & Accountability**
* authorship
* proper citation and referencing
* [PEP8 for Python](https://peps.python.org/pep-0008/) # Reproducibility
* C++ does not have an official guidline, but [Stroustrup and Sutter](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md) is a good starting point
## Clean Code ## What do we want to reproduce? {.special}
* delete unused code blocks and only keep as few code as necessary
* fewer lines of code -> fewer bugs (add source to this statement)
* BUT: optimization should be in balance with code readability. Convoluted statements are ok if they improve the code efficiency, but might need to be accompanied by some sort of documentation.
## Efficient Code ::: {.fragment}
::: {.smaller} *the argument*
A collection and repetition of statements from previous lectures
::: :::
* use math if you can, else, keep the order of complexity of your code in mind and check whether it behaves as you'd expect (complexity lecture) ## What is needed to reproduce the argument? What do we need to save and how? {.special}
* reduce loops by vectorizing operations, e.g. in Python by using list comprehensions(?)
* efficient memory usage (memory?)
* use parallel processing if you can pinpoint the performance bottleneck to a task that can be split between multiple processors. (parallel programing?)
* ...
## Understandable Code / Documentation ## What should we document? {.special}
code should be clear in itself, but also accompanied by a statement of its purpose and proper usage. Additional information could include input/output, author, or date information.
* in-line documentation: docstrings are string literals written into your code (add example?) ## FAIR data
* comments * state the ideas and problems of FAIR data
* separate documentation: common format is a text file, e.g. README.txt, or a chapter in a linked documentation file or handbook
## Version control for code changes ## Which tools shall we use?
A version control software ensures a tracable record of code changes, it serves as a backup and is indispensible in any collaborative code development. * open source / development
* trustworthy sources
## Testing and Code Review ## Summary on Reproducibility
* save the primary data needed to reproduce the argument of your scientific study
## Staying up to date # Respect & Accountability
* stay up to date with coding trends and libraries *What shall we credit and how?*
* be open and continue learning: new technologies typically improve your productivity
## Authorship versus Acknowledgment
## Licenses
CC0 versus CC-BY
## Intellectual Property (IP)
## Using AI
## Summary on Authorship and Credit
# Good Coding Practice
## Good Coding Practice
* clean code: easier to understand for any reviewer and most important, fewer lines of code -> fewer bugs
* efficient code
* use math if you can, else, keep the order of complexity of your code in mind and check whether it behaves as you'd expect
* use parallel processing if you can pinpoint the performance bottleneck to a task that can be split
## Good Coding Practice
* understandable code: code should be clear in itself, but also accompanied by a statement of its purpose and proper usage (documentation).
* trustworthy code: testing and code review
* tracable code changes: version control ensures a tracable record of code changes, it serves as a backup and is indispensible in any collaborative code development.
# Summary
Good Scientific Practice ensures research integrity and the advancement of knowledge.
# Good scientific practice
* Use trustworthy sources * Use trustworthy sources
* understand your code * understand your code
* communicate the license * communicate the license
* give credit to contributors * give credit to contributors
* respect intellectual property (IP) * respect intellectual property (IP)
* stay up to date with coding trends and libraries
* be open and continue learning: new technologies typically improve your productivity :)
## Licenses # Disclaimer
*This lecture was designed with the help of the Large Language Model OpenAI GPT-4.*
CC0 versus CC-BY
## credit
## IP # Further Reading
* [European Code of Conduct for Research Integrity](https://allea.org/wp-content/uploads/2023/06/European-Code-of-Conduct-Revised-Edition-2023.pdf)
* [DFG Guidlines for Safeguarding Good Research Practice. Code of Conduct](https://zenodo.org/records/6472827)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment