reading-notes

This Repo required for Asac labs class 2


Project maintained by ManarAbdelkarim Hosted on GitHub Pages — Theme by mattgraham

Read: 09 - Refactoring

Complexity is anything that makes software hard to understand or to modify. immutability and pure function are big advantages to build side-effect-free functions, so it is easier to maintain systems. Immutability Unchanging over time or unable to be changed.

Functional Programming

FUNCTIONAL PROGRAMMING

Functional Programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.

In other words, the program should return new data without modifying the original data.

pure functions

The first fundamental concept we learn when we want to understand functional programming is pure functions.

Functions as first-class entities can:

example:

let counter = 1;
function increaseCounter (value) {counter = value + 1;}
increaseCounter(counter);
console.log(counter); // 2
let counter = 1;
function increaseCounter (value) { value + 1;}
increaseCounter(counter); // 2
console.log(counter); // 1

Pure functions benefits

Unchanging over time or unable to be changed. When data is immutable, its state cannot change after it’s created. If you want to change an immutable object, you can’t. Instead, you create a new object with the new value.

Refactoring JavaScript

some straightforward to implement methods that can lead to easier-to-read code.

It’s important to get your code right the first time because in many businesses there isn’t much value in refactoring. Or at least, it’s hard to convince stakeholders that eventually uncaged for codebase will grind productivity to a halt.