Last active
October 18, 2024 19:43
-
-
Save zehan12/e628fdcd4d8a3b26fbf0dd927ef4d605 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 User { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| } | |
| class UserRepository { | |
| save(user) { | |
| console.log(`Saving ${user.name} to the database.`); | |
| } | |
| } | |
| class WelcomeMailer { | |
| sendEmail(user) { | |
| console.log(`Sending welcome email to ${user.name}.`); | |
| } | |
| } | |
| const user = new User("Zehan"); | |
| const repo = new UserRepository(); | |
| const mailer = new WelcomeMailer(); | |
| repo.save(user); // Saving Zehan to the database. | |
| mailer.sendEmail(user); // Sending welcome email to Zehan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment