Tuesday, May 29, 2012

Design Pattern

What is a design pattern?
Pattern describes a problem which occurs over and over again in a context, and then describes the core of the solution to that problem, in such a way that you can use this core of solution a million times over, without ever using it the same way twice.
  • Language-independent strategies for solving common object-oriented design problems
  • Common solution to common problem in context and system of forces
  • Solution to a narrowly-scoped common technical problem
  • Abstraction from a concretion recurring in specific, non-arbitrary contexts
  • Successfully recurring best practice that has proven itself in the trneches
  • A literary format for capturing wisdom and experience of expert designers, and communicating it to novices.
Why design pattern?
Designing object-oriented code is hard, and designing reusable object-oriented software is even harder - Why?
Patterns enable programmers to recognize a problem and immediately determine the solution without having to stop and analyze the problem first.
Provides a framework for communicating complexities of OO design at a high level of abstraction
Bottom line: Design Productivity
  • Solve "real world" problems
  • Capture domain expertise
  • Document design decisions and rationale
  • Reuse wisdowm and experience of practitioners
  • Convey expert insight
  • Shared vocabulary for problem-solving
  • Show more than just the solution
  • Teaches OO way!
Object Oriented Pillars
  1. Abstraction
    • Getting something out
    • A process of classifying objects
    • E.g. Men, women, car, window
    • A class of objects
  2. Encapsulation (and Polymorphism)
    • Getting something hidden
    • Something private that can be access through a public functionYou hide a private implementation inside a public interface
    • Poly: One interface, multiple implementation
    • Simplifies source code
  3. Modularity
    • Has the ability to disassemble & assemble back easily (without too much time)
    • Can work on module parallel
    • Each module less independent
  4. Hierarchy
    • Inheritance
    • Referential - one refer to one

No comments: