Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SOLID [L] Wrong Abstraction
public class Transaction
{
public virtual long OriginalAmount { get; set; }
public virtual long InterestAmount { get; set; }
}
public class CreditCardTransaction : Transaction
{
}
public class PixTransaction : Transaction
{
public override long InterestAmount
{
get { throw new InvalidOperationException(); }
set { throw new InvalidOperationException(); }
}
}
// class that needs transaction
public class Order
{
// ctor and some properties
public long TotalPaid { get; private set; }
public void AddTransaction(Transaction transaction)
{
this.TotalPaid += transaction.OriginalAmount;
this.TotalPaid += transaction.InterestAmount;
// do something more
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment