Rule of Least Power — Know What to Use & When

Image for post
Image for post
Mallet vs. Flyswatter: thenounproject.com

Progression of Language Constructs Resulting in Improvements of Clarity

Spaghetti Code

Image for post
Image for post
Spaghetti Code: callabsolutions.com/spaghetti-code-vs-structured-code

Mallet vs. Flyswatter

/* OBJECTIVE: FIND EVEN NUMBERS (KILL THE FLY) */ function useMallet(arr: number[]): number[] {
let evens: number = [];
// More 'powerful', can be applied to more situations
for (let i = 0; i < arr.length; i++) {
if (arr[i] % 2 === 0) {
evens.push(arr[i]);
}
}

return evens;
}
function useFlySwatter(arr: number[]): number[] {
// Less 'powerful', can be applied to less situations
return arr.filter(num => num % 2 === 0);
}
const numbers = [1, 2, 3, 4, 5, 6];
const withMallet = useMallet(numbers); // [2, 4, 6]
const withFlySwatter = useFlySwatter(numbers); // also [2, 4, 6]

Patterns of Discovering Improvements in Clarity

Image for post
Image for post
Progression of Abstraction
Image for post
Image for post
Continued Progression of Abstraction

Necessary Tasks for Improvements in Clarity to be Adopted

Bilingual Software Developer | Always open to new contacts & opportunities

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store