15
2 STYLE – what ? Programming style is a set of rules or guidelines used when writing ... code. https://en.wikipedia.org/wiki/Programming_style Style concerns everything: files, functions, objects, arguments, names, spacing, indenting, assignment, quotes, comments, pipes, capitalization, punctuation, and so on...

Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

2

STYLE – what ?

Programming style is a set of rules orguidelines used when writing ... code.

https://en.wikipedia.org/wiki/Programming_style

Style concerns everything: files, functions, objects, arguments, names, spacing, indenting,assignment, quotes, comments, pipes, capitalization, punctuation, and so on...

Page 2: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

3

STYLE – why?

… following a particular programming stylewill help programmers read and understandsource code conforming to the style, and helpto avoid introducing errors.

https://en.wikipedia.org/wiki/Programming_style

Page 3: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

4

STYLE – where?

There is no agreed upon style in the Renvironment. But choose one and stick to it.

Tidyverse Styleguidehttp://style.tidyverse.org/

rOpenSci Packaging Guidehttps://github.com/ropensci/onboarding/blob/master/packaging_guide.md

Google’s Styleguidehttps://google.github.io/styleguide/Rguide.xml

Page 4: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

5

DOCUMENTATION – what ?

… documentation is written text ... that accompanies ... or isembedded in ... code. It either explains how [the code]operates or how to use it ... https://en.wikipedia.org/wiki/Software_documentation

Page 5: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

6

DOCUMENTATION – why?

Code should be easy to understand

That means that it should be written to minimise the time it would takefor someone else to understand it.

The purpose of commenting is to help the reader know as much as youdid when you wrote the code and everything was fresh in yourmemory.

That reader could very well be future you. And we all know past youwon’t answer emails.

Page 6: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

7

DOCUMENTATION – where?

Tidyverse Styleguidehttp://style.tidyverse.org/

rOpenSci Packaging Guidehttps://github.com/ropensci/onboarding/blob/master/packaging_guide.md

R packageshttp://r-pkgs.had.co.nz/

The Art of Readable Codehttps://www.amazon.com/Art-Readable-Code-Practical-Techniques/dp/0596802293

Page 7: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

8

GIT – what ?

Git is a version control system fortracking changes in computer files andcoordinating work on those files amongmultiple people. It is primarily used forsource code management in softwaredevelopment…

https://en.wikipedia.org/wiki/Git

Page 8: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

9

GIT – why?

Data science ISsoftwaredevelopment…and you need touse git every time.

Page 9: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

10

GIT – where?

Git and GitHubhttp://r-pkgs.had.co.nz/git.html

Version Control with Git and SVNhttps://support.rstudio.com/hc/en-us/articles/200532077-Version-

Control-with-Git-and-SVN

A successful Git branching modelhttp://nvie.com/posts/a-successful-git-branching-model/

Page 10: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

11

TEST – what ?

In computer programming, unit testing is asoftware testing method by which individualunits of source code, sets of one or morecomputer program modules together withassociated control data, usage procedures,and operating procedures, are tested todetermine whether they are fit for use.

https://en.wikipedia.org/wiki/Unit_testing

Page 11: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

12

TEST – why?

Testing makes sure that your code works –and that it works the way you want it to.

Testing gives you fewer bugs, a bettercode structure, easier restarts and morerobust code.

CRAN checks also greatly improve yourpackage.

Page 12: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

13

TEST – where?

Chapter: Testinghttp://r-pkgs.had.co.nz/tests.html

testthat packagehttps://github.com/r-lib/testthat

devtools packagehttps://www.rstudio.com/products/rpackages/devtools/

Page 13: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

14

DOCKER – what ?

Docker is a computer program that performsoperating-system-level virtualization also known ascontainerization.

Docker uses resource isolation to allowindependent ”containers” to run within a single OS,avoiding the overhead of starting and maintainingvirtual machines (VMs).

Page 14: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

15

DOCKER – why?

Docker can create the exact environment that youneed for your analysis.Once build you can use this image every time youneed to run the given analysis.The processes will be totally isolated and softwareyou run or update will have no effect outside of thegiven container.And you can chain them together in powerfuldocker-recipes using docker compose.

Page 15: Programming style is a set of rules or ...2018.erum.io/slides/lightning talks/Mikkel Freltoft Krogsholm.pdf3 STYLE –why? …followingaparticularprogrammingstyle willhelpprogrammersreadandunderstand

16

DOCKER – where?

Rockerhttps://github.com/rocker-org/rocker

Docker tutorialhttps://docs.docker.com/get-started/

Dockerhubhttps://hub.docker.com/explore/