Last active
August 22, 2023 00:06
-
-
Save mcsee/388923d775ca893eb1e6ca4c28c3287f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Teacher { | |
static getByID(id) { | |
// This is coupled to the database | |
// Thus violating separation of concerns | |
} | |
constructor(id, fullName) { | |
this.id = id; | |
this.fullName = fullName; | |
} | |
} | |
class School { | |
static getByID(id) { | |
// go to the coupled database | |
} | |
constructor(id, address) { | |
this.id = id; | |
this.address = address; | |
} | |
} | |
class Student { | |
constructor(firstName, lastName, id, teacherId, schoolId) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.id = id; | |
this.teacherId = teacherId; | |
this.schoolId = schoolId; | |
} | |
school() { | |
return School.getById(this.schoolId); | |
} | |
teacher() { | |
return Teacher.getById(this.teacherId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment