Code Monkey home page Code Monkey logo

caringaboutcode's Introduction

Caring About Code

Slides for the presentation Caring About Code. This talk was initially presented at the Plant Production System seminar at Wageningen University. It is mostly aimed at R beginners.

Link to the slides: https://alanguillaume.github.io/CaringAboutCode/

Summary:

Code should be understood as a research project blue-print that allows one’s results to be easily reproduced by anyone starting from their author. However, code should not only be machine-readable but also human-readable and, as such, should be treated as a communication medium in its own right. If tackling your coding problems with that given mindset, you can directly use what you already know about writing in general to improve your code. That boils down to:

  1. Enough vocabulary: to simply know what to google.

  2. Clear Syntax: Once you know enough words you can arrange them in properly layed-out sentences.

    • Let the code breathe: Code also likes spaces and escaped lines.
    • Be explicit: in the way you name things.
    • Be consistent: in the way you name things (bis) but…
    • DRY: Don’t Repeat Yourself.
    • The Torah Syndrome: limit yourself to 80 characters per line.
  3. Clear Structure: Once you know how to write sentences you can arrange them in paragraphs. The general idea of one paragraph = one idea also holds for code and comes in the name of modularity.

    • Write a few small scripts each doing one thing well.
    • Whenever needed, write functions (automation recipes) and put them all together in a “toolbox” script.

Companion Example:

All the above points are illustrated in a companion project: blackadder. In that small example, I made a heavy use of the tidyverse especially stringr and purrr to clean data (Enough Vocabulary). The data and analysis are a bit unorthodox but the objective was to focus on the code layout (Clear Syntax) and the project architecture (Clear Structure).

Additional links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.