Skip to content

Instantly share code, notes, and snippets.

@konami12
Last active September 2, 2020 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konami12/3039456df210421462f07934cdd269bd to your computer and use it in GitHub Desktop.
Save konami12/3039456df210421462f07934cdd269bd to your computer and use it in GitHub Desktop.
✅ Principio de Responsabilidad Única
class Pokemon {
 #name = ""; 
 #type = ""
 #evolutions = [];
 constructor(name, type, evolutions) {
 this.#name = name;
 this.#type = type;
 this.#evolutions = evolutions;
 }
get name() {
return this.#name;
}
get type() {
return this.#type;
}
get evolutions() {
return this.#evolutions;
}
}
/*
para aplicar el principio de responsabilidad única
separamos todas las operaciones que tengan que ver
con acciones dentro de la base de datos.
*/
class DataBase {
// Método principal
constructor(pokemon) {}
saveData() { ... }
findData() { ... }
updateData() { ... }
deleteData(){ ... }
}
// Creamos la instacia de la clase pokemon
const Eevee = new Pokemon("Eevee", "normal", ["Jolteon", "Vaporeon", "Flareon"]);
// pasamos los la instancia del pokemon
const DB = new DataBase(Eevee);
// creamos un nuevo registro
DB.saveDateDB(Eevee);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment