Summary: give a SOLID DRY KISS
-
- HT give names
- Avoid adding the type in the name e.g. viewerArray when unneded
- Sometimes there’s no better alternative though
- In cases where the 2 refer to the same thing I find best to add the type because the alternatives seems too verbose or less clear and may confuse devs more
- const videoLengthString = element.parentElement.parentElement.parentElement.parentElement.innerText - const videoLengthArray = videoLengthString.split(”:”); - if (videoLengthArray.length === 2) videoLengthArray.unshift(“0”)
- Sometimes there’s no better alternative though
- Expand abbreviations when needed calculate(n) → calculate(num)
- Use names to give nuance in the code in a specific way
- before
- after
- before
- No magic values giveMeThat(“thing”) → giveMeThat(pizzaIWantToGet)
- Avoid adding the type in the name e.g. viewerArray when unneded
- KISS - Keep It Simple, Stupid
- Find the best laziest alternative
- don’t overengineer expecially at the start and focus on making stuff work first
- DRY - Don’t Repeat Yourself (with the code)
- HT give names
- 2
- SOLID
- Single responsability - don’t make the code be a jack
- a function should do 1 thing and not multiple at the same time
- Open/Closed - add but be esitant to modify code
- Liksov substitution
- Interface segregation - give modules just the necessary to talk w other one
- if he’s communicating with the DB he don’t need the whole logic but just a query function maybe
- Dependency inversion - let 2 modules communicate just with abstractions not directly
- Single responsability - don’t make the code be a jack
- SOLID