USING INTERFACE ABSTRACT CLASS STRATEGY Many object-oriented programmers get confused about using an abstract class vs. using an interface. They argue over whether it's better to provide an interface structure with no implementations or an abstract class structure with only single inheritance. The best way is to employ the Interface Abstract Class strategy. Nine times out of 10 you'll be right. Any nonsimple code can be implemented as: Interface ^ | Abstract ^ | Class The abstract class should provide any default implementation for the system and/or a static registry for the Abstract Factory pattern. Interfaces are important for object orientation. OO is about types, not classes. Classes are implementations. They're essential for a system to run and exist, but the system types are all that's needed at the design stage. If you always provide an interface, your code can fully participate in the object experience. [javacode] // Anything can implement this and act like a Vending Machine public interface VendingMachine { public boolean acceptCurrency(Currency currency); public StockList getCurrentStock(); public PriceList getPriceList(); } [/javacode] While the interface provides a great way to type classes, it doesn't allow for any common implementation across a type. This is where the abstract class comes in. It allows for use of common code in every extension. [javacode] // A Vending Machine that only works with US Currency abstract public class AbstractUSVendingMachine { public boolean acceptCurrency(Currency currency) { if(currency == null) { return false; } else { return (currency.getType() == Currency.USD); } } } [/javacode] The biggest abstract class problem is that the code is pinned to a single inheritance model. But by using the interface as well, a delegate or other system may be used to get around the issue. [javacode] // A delegate to allow Washing Machine's to be Vending Machines public class HotPointWashingMachine extends AbstractWashingMachine implements VendingMachine { private VendingMachine vendingDelegate; public HotPointWashingMachine() { super(); this.vendingDelegate = new HotPointVendingMachine(); } // VendingMachine interface public boolean acceptCurrency(Currency currency) { return this.vendingDelegate.acceptCurrency(currency); } public StockList getCurrentStock() { return this.vendingDelegate.getCurrentStock(); } public PriceList getPriceList() { return this.vendingDelegate.getPriceList(); } // End of VendingMachine } class HotPointVendingMachine extends AbstractVendingMachine { public PriceList getPriceList() { .... } public StockList getCurrentStock() { .... } } [/javacode] ------------------------------------------