diff --git a/_quarto.yml b/_quarto.yml index dd0f9f57d281ede6b55cc660c51255816b6ce695..f8fcd0e5728363a6b40cb7510e9730627a3af6e6 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -34,7 +34,7 @@ website: - "lectures/data-structures/slides.qmd" - "lectures/complexity/slides.qmd" - "lectures/debugging-strategies/slides.qmd" - # - "lectures/good-scientific-practice/slides.qmd" + - "lectures/good-practice/slides.qmd" - "lectures/user-experience/slides.qmd" - "lectures/testing/slides.qmd" - "lectures/git2/slides.qmd" @@ -50,7 +50,6 @@ website: - "exercises/data_structures.qmd" - "exercises/complexity.qmd" - "exercises/debugging-strategies.qmd" - # - "exercises/good_scientific_practice.qmd" - "exercises/user-experience.qmd" - "exercises/testing.qmd" - "exercises/git2/exercise.qmd" diff --git a/lectures/good-practice/slides.qmd b/lectures/good-practice/slides.qmd new file mode 100644 index 0000000000000000000000000000000000000000..0d976103914c209a688c08a77adf41e2be6ad4fc --- /dev/null +++ b/lectures/good-practice/slides.qmd @@ -0,0 +1,67 @@ +--- +title: "Good scientific and coding practice" +author: "Bjorn Stevens and Theresa Mieslinger" +--- + +# Good coding practice +***consistency is the key*** + +* clean code +* efficient code +* understandable code +* tracable code changes + +## Style Guides +***code is read much more often than it is written*** + +Each programing language has it's own guidlines: + +* [PEP8 for Python](https://peps.python.org/pep-0008/) +* 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 +* 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 +::: {.smaller} +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) +* 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 +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?) +* comments +* 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 +A version control software ensures a tracable record of code changes, it serves as a backup and is indispensible in any collaborative code development. + +## Testing and Code Review + +## Staying up to date +* stay up to date with coding trends and libraries +* be open and continue learning: new technologies typically improve your productivity + +# Good scientific practice +* Use trustworthy sources +* understand your code +* communicate the license +* give credit to contributors +* respect intellectual property (IP) + +## Licenses + +CC0 versus CC-BY + +## credit + +## IP