Why Design Pattern In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson und John Vlissides published a book titled Design Patterns - Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development. The idea was to compile a list of common design patterns which can be used by programmers while designing the complex software. All the design patterns in this book are based on the two principles: • Program to an interface, not an implementation. • Favor object composition over inheritance. Let's discuss these two principles in detail. Program to an interface, not an implementation: This principle means that when we create an object, we should create an object for the interface and not the implementation. Example: ArrayList myList = new ArrayList(); //Bad List myList = new ArrayList(); //Good List myList = new TreeList(); // Good In this example...
Comments
Post a Comment