Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

Design Patterns in Java

Lars Vogel

Version 0.4

30.12.20010

Revision History
Revision 0.102.07.2007Lars Vogel
created
Revision 0.402.09.2007 - 30.12.20010Lars Vogel
bug fixes and updates

Design Pattern

Design Patterns are best practices how to solve common know problems. This article will give an overview of best practices in object-orientated programming and has pointers to some design-pattern tutorials.


Table of Contents

1. Introduction
2. Object Orientated Programming
2.1. Encapsulation
2.2. Abstraction
2.3. Polymorphisms
2.4. Inheritance
2.5. Delegation
2.6. Composition
2.7. Aggregation
2.8. Design by contract
2.9. Cohesion
2.10. The Principle of Least Knowledge
2.11. The Open Closed Principle
3. Pattern
4. Thank you
5. Questions and Discussion
6. Links and Literature

1. Introduction

The terminology of "Design Pattern" in software developed is based on the GOF (Gang of Four) book "Design Patterns - Elements of Reusable Object-Oriented Software" from Erich Gamma, Richard Helm, Ralph Johnson und John Vlissides. Design Pattern are proven solutions approaches to specific problems. A design pattern is not framework and is not directly deployed via code.

Design Pattern have two main usages:

  • Common language for developers: They provide developer a common language for certain problems. For example if a developer tells another developer that he is using a Singleton, the another developer (should) know exactly what this means.

  • Capture best practices: Design patterns capture solutions which have been applied to certain problems. By learning these patterns and the problem they are trying to solve a unexperienced developer can learn a lot about software design.

Design pattern are based on on the basis principles of object orientated design.

  • Program to an interface not an implementation

  • Favor object composition over inheritance

Design Patterns can be divided into:

  • Creational Patterns

  • Structural Patterns

  • Behavioral Patterns