KISS
Example Illustrating the KISS Principle

Consider a function that calculates the total price of items in a shopping cart, including tax:

Complex Implementation

public class ShoppingCart
{
    private List items;
    private double taxRate;

    public ShoppingCart(double taxRate)
    {
        this.items = new List();
        this.taxRate = taxRate;
    }

    public void AddItem(Item item)
    {
        items.Add(item);
    }

    public double CalculateTotalPrice()
    {
        double totalPrice = 0;
        foreach (var item in items)
        {
            totalPrice += item.Price * item.Quantity;
        }
        double tax = totalPrice * taxRate;
        return totalPrice + tax;
    }
}

public class Item
{
    public double Price { get; set; }
    public int Quantity { get; set; }
}

Simplified Implementation

public class ShoppingCart
{
    private List items;
    private double taxRate;

    public ShoppingCart(double taxRate)
    {
        this.items = new List();
        this.taxRate = taxRate;
    }

    public void AddItem(Item item)
    {
        items.Add(item);
    }

    public double CalculateTotalPrice()
    {
        double subtotal = items.Sum(item => item.Price * item.Quantity);
        return subtotal * (1 + taxRate);
    }
}

public class Item
{
    public double Price { get; set; }
    public int Quantity { get; set; }
}