Last active
May 6, 2021 06:20
-
-
Save ThiagoBarradas/ba35f689b8158b9558e44bcdeae75a2a to your computer and use it in GitHub Desktop.
SOLID [D] - Wrong implementation with high coupling
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
public class CreditCard | |
{ | |
public bool Pay(int amount) | |
{ | |
// do something | |
} | |
} | |
public class Person | |
{ | |
public CreditCard CreditCard { get; set; } | |
public Person(CreditCard creditCard) | |
{ | |
this.CreditCard = creditCard; | |
} | |
} | |
// calling | |
CreditCard creditCard = new CreditCard(); | |
Person person = new Person(creditCard); | |
person.CreditCard.Pay(100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment