brad-cannell / r4epi

Repository for the R for Epidemiology book
http://www.r4epi.com/
Other
18 stars 50 forks source link

Make an R style guide appendix #86

Open mbcann01 opened 1 year ago

mbcann01 commented 1 year ago

Overview

Style, and misuses of it, are one of the biggest issues I see with student code. I think it would be helpful to create a style guide appendix. I imagine it would be similar to the Tidyverse style guide.

I don't think this should replace the chapter on style best practices. It should augment it. Tell them to use this appendix to look things up.

You may want to include something like this snippet you wrote for your Power Automate wiki:

This page will serve as a style guide for authoring this wiki and for authoring Power Automate flows. The ultimate goal of a style guide is to reduce cognitive load, and as a result, make it easier to write - text or code. How does a style guide do this? First, it reduces the number of choices you have to make as you are writing. For example, "should I write this variable name in snake case or camel case?" Second, having the predetermined choices written down for references reduces the amount of information you need to store in your intentional memory (i.e., "OK, remember to always use snake case"); although, it may eventually bleed over into your incidental memory. Third, having uniformly styled text/code makes it easier for others -- including future you -- to read. You can focus on the content instead of the style and/or organization.

mbcann01 commented 1 year ago

For functions that span more than one line