Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 742 Bytes

File metadata and controls

29 lines (19 loc) · 742 Bytes

Do not Repeat Yourself - DRY rule

vs. Write Everything Twice - WET rule


Following the WET rule will:
  • Increase the difficulty of change
  • Decrease clarity
  • Leads to opportunities for inconsistency

To prevent duplication and follow the DRY rule, we can write custom functions.
  • AwesomeFunctionName <- function(argument1, argument2,…){ do stuff here }

To build up a function, start by writing the "stuff" to test that it works outside the function.


YOUR TURN:
Create a function that draws a histogram of nrep mean(rnorm(100))
Modify your function to draw a histogram of nrep mean(rnorm(n))


Previous | Next