Skip to content

Instantly share code, notes, and snippets.

@gutomarzagao
Created October 23, 2022 21:16
Show Gist options
  • Select an option

  • Save gutomarzagao/c47ef622e714a052a3b1de648330ac3b to your computer and use it in GitHub Desktop.

Select an option

Save gutomarzagao/c47ef622e714a052a3b1de648330ac3b to your computer and use it in GitHub Desktop.
7 erros de clean code
import db from '@/db'
class Author {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.fullName = firstName + ' ' + lastName
}
update(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.fullName = firstName + ' ' + lastName
this.save(this.firstName, this.lastName)
}
save(firstName, lastName) {
db.saveAuthor(firstName, lastName)
}
getBooksByGenre(genre) {
const books = []
const allAuthorBooks = db.getAuthorBooks(this.firstName, this.lastName)
allAuthorBooks.forEach(book => {
const genreModel = db.getGenreById(book.genre_id)
if (genreModel.name === genre) {
books.push(book)
}
})
return books
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment