clean-code-javascript icon indicating copy to clipboard operation
clean-code-javascript copied to clipboard

Outras ideias para melhorar o código

Open Gurigraphics opened this issue 6 years ago • 3 comments

Learn with Jquery how to use the vanilla javascript

Bad:

var a = document.getElementById("a")
var b = document.getElementById("b")
var c = document.getElementsByClassName("c")
var d = document.getElementsByTagName("body")[0]

Good:

const $ = (v) => document.querySelector(v)

let a = $("#a")
let b = $("#b")
let c = $(".c")
let d = $("body")

Stop repeating console.log

Bad:

console.log(a)
console.log(b)
console.log(c)
console.log(d)

Good:

const log = (v) => console.log(v)

log(a)
log(b)
log(c)
log(d)

Sugeri estas ideias no repositório inglês, mas não aceitaram. Se quiser adicionar apenas na versão português...

Opinião do bot gringo:

  • Hey there! I only want to add subsections that have a corresponding one in the book Clean Code. I don't think this one does.

Minha opinião:

  • Is the goal to write cleaner code, or philosophize about the book?

Gurigraphics avatar Jan 22 '20 17:01 Gurigraphics

Closed discussion link: https://github.com/ryanmcdermott/clean-code-javascript/issues/293

Gurigraphics avatar Jan 22 '20 23:01 Gurigraphics

Achei ótimas ideias @Gurigraphics !!

ficast avatar Jul 27 '20 22:07 ficast

@ficast Como só aceitavam conteúdo do livro coloquei as ideias aqui https://github.com/Gurigraphics/javascript

Gurigraphics avatar Jul 30 '20 22:07 Gurigraphics