Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IDatabaseV1 cust = new CustomerWithRead();

            cust.Add();

            cust.Read();
        }
Exemple #2
0
        // e.g.
        private void ManipulateCustomers()
        {
            var database = new Database();
            var customer = new Customer();

            customer.Add(database); // Old functionality, works fine
            var readCustomer = new CustomerWithRead();

            readCustomer.Read(); // Good! New functionalty is separate from existing customers
        }
        public void TestCustomersTest()
        {
            ICustomer   customer     = new CustomerInterface();
            ICustomerV1 readCustomer = new CustomerWithRead();

            Assert.IsInstanceOfType(customer, typeof(ICustomer));
            Assert.IsNotInstanceOfType(customer, typeof(ICustomerV1));
            Assert.IsInstanceOfType(readCustomer, typeof(ICustomer));
            Assert.IsInstanceOfType(readCustomer, typeof(ICustomerV1));
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            List <CustomerOCP> Customers = new List <CustomerOCP>();

            Customers.Add(new SilverCustomer());
            Customers.Add(new GoldCustomer()); // Using OCP
            Customers.Add(new Enquiry());      // Using ISP

            foreach (CustomerLSP o in Customers)
            {
                o.Add();
            }

            IDatabase i = new CustomerLSP();          // 1000 happy old clients not touched

            i.Add();                                  // using Liskov

            IDatabaseV1 iv1 = new CustomerWithRead(); // new clients

            iv1.Read();
        }