Skip to content

Instantly share code, notes, and snippets.

@benkoshy
Created April 12, 2017 23:55
Show Gist options
  • Select an option

  • Save benkoshy/92da718093a262ce3707d92a1f3189b1 to your computer and use it in GitHub Desktop.

Select an option

Save benkoshy/92da718093a262ce3707d92a1f3189b1 to your computer and use it in GitHub Desktop.
Depend on behaviour not data - All the changes that would have to be made if something changed.
    /// One GBP sterling is worth 1.25 USD.
    /// We'd have to change the code to reflect this.
    class Program
    {
        static void Main(string[] args)
        {
            Account freddie = new Account(5000000);

            // freddie buys a grand piano
            freddie.balance = freddie.balance * 1.25m - 500000m;

            // freddie buys a leather jacket
            freddie.balance = freddie.balance * 1.25m - 5000m;

            // freddie buys a beer in Singapore
            freddie.balance = freddie.balance * 1.25m - 20;            
        }                
    }


    public class Account
    {
        public decimal balance;

        public Account(decimal balance)
        {
            this.balance = balance;
        }
    }
    ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment