Skip to content

Instantly share code, notes, and snippets.

@kibolho
Created July 21, 2021 19:42
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 kibolho/d00eccbe0d47b0c151dfee012894cebe to your computer and use it in GitHub Desktop.
Save kibolho/d00eccbe0d47b0c151dfee012894cebe to your computer and use it in GitHub Desktop.
SOLID -Single Responsibility Principle
class Car {
constructor(name,model,year) {
this.name=name
this.model=model
this.year=year
}
getCar(id) {
return this.http.get('api/cars/'+id)
}
saveCar() {
return this.post('api/cars', { name: this.name, year: this.year, model: this.model })
}
}
class Car {
constructor(name, model, year) {
this.name = name
this.model = model
this.year = year
}
}
class CarService {
getCar(id) {
return this.http.get('api/cars/'+id)
}
saveCar(car) {
this.http.post('api/cars', car)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment