I'm trying to understand the sweet spot between readability vs repeating myself in my code.
I'm creating Conway's game of life in Javascript. My functions use many of the same variables over and over again like so...
const BOARD_HEIGHT = 50
const BOARD_WIDTH = 50
let gameBoard = createGameBoard();
function createGameBoard(width, height){}
function randomizeGameBoard(gameBoard, width, height){}
function updateGameBoard(gameBoard, width, height){}
function runGameLoop(gameBoard, width, height){}
Should I declare functions like this? Where all functions take in the exact same parameters OR should my functions NOT take parameters and instead access commonly used variables directly (globals)?
function createGameBoard() {do stuff with BOARD_WIDTH, BOARD_HEIGHT};
function randomizeGameBoard() {do stuff with gameBoard};