Created
March 21, 2025 17:46
-
-
Save trikitrok/ff63dae0bb7e2cf48d7888a63182454c 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 RegisterSale { | |
// more code... | |
public addItem(code: Barcode): void { | |
//!! After Extract Method | |
const newItem = this.getInventory().getItemForBarCode(code); | |
this.items.push(newItem); | |
} | |
//!! Extracted method. Now we can apply Subclass & Override Method here!! | |
private getInventory(): Inventory { | |
// still using the Singleton!! | |
return Inventory.getInstance(); | |
} | |
// more code... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment