crumbs and chunks of knowledge

Miscellaneous / unsorted

Programming principles

summarized from this piccalilli article:

Programming principles for self taught front-end developers

The majority of us are a bunch of self taught people with rather spotty knowledge and that's fine! Kilian (also self taught) is here to share some of the computer science fundamentals you probably are missing with the aim to improve your code in the long term.

the rule of three: generalize/abstract a functionality only when you have had to repeat the code three times.

firstly: you write some code.

secondly: you realize you need to reuse the same code in another place. don’t generalize yet. just copy-paste your code over. it’s fine. generalizing a functionality that’s only reused twice is over-engineering.

thirdly: now it’s time to generalize. this is also likely the point where you have a clearer idea how best to abstract the functionality for three different use cases.

make it work, make it right, make it fast, in that order.

write idempotent functions, which are functions that always return the same output given the same input. deterministic, i suppose?

single responsibility principle.

try to describe a function in english. if you catch yourself saying “and”, it probably violates this principle.

maintain a single level of abstraction/detail in each function. don’t mix high-level business logic with database access.

Github-flavored Markdown

footnotes

Cookies are delicious.[^cookies]

[^cookies]: Well, except pineapple-flavored ones.

renders to:

(i don't actually know of any pineapple-flavored cookies this was just something random)