1 / 20

Creational

Behavioral. Paradigm Shift, Inc. Software Factory. Creational. Structural. Lesson 1: Introduction. Object-Oriented. Patterns. Design. Lesson Objectives. Be able to use patterns to define good design Understand why design patterns are important

omer
Télécharger la présentation

Creational

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Behavioral Paradigm Shift, Inc. Software Factory Creational Structural Lesson 1:Introduction Object-Oriented Patterns Design

  2. Lesson Objectives • Be able to use patterns to define good design • Understand why design patterns are important • Discuss the process of discovering design patterns • Present other common techniques for reuse • Learn the answers of the following questions: • What is a pattern? • Where can we look to understand more about patterns? • What are some examples of what might be considered patterns? and how can we catalog them? • What is the process of discovering patterns? • What is the potential impact of patterns?

  3. Introduction • Object-oriented design patterns and frameworks help to improve key software quality factors • e.g., reuse, extensibility, modularity, performance • OO design patterns support reuse of software architecture • Design patterns capture the static and dynamic structures and collaborations of successful solutions to problems that arise when building applications in a particular domain. • Frameworks support reuse of design and code • A framework is a set of cooperating classes that make up a reusable design for a specific domain

  4. Design Patterns: Properties & Definitions • [Webster] A pattern is a fully realized form, original, or model accepted, or proposed for imitation. • [Webster] A pattern is something regarded as normative example to be copied; archetype ; exemplar . • [Alexander 79] A pattern is a solution to a problem in a context. • [Alexander 79] A pattern has three parts: • Problem(s) • Context • Solution • A pattern offers a workable solutions. • Patterns are rules of thumbs that can be used again and again -- useful, practical “how-to” guideline.

  5. Design Patterns: More Properties & Definitions • [Gamma 95.] Design patterns identify, name, and describe common and recurring designs appearing frequently in object-oriented systems. • [Gamma 95] You can think of a design pattern as a micro architecture that contributes to overall system architecture. • Each design pattern tends to be relatively small in size and scope. • [Coplien 92] Patterns are a way of describing, documenting, and creating system architectures for software. • Patterns tend not to be domain specific. • Patterns are one of the primary mechanisms that people use for passing on expertise to others.

  6. Patterns of Learning • Solutions to most challenging areas of human endeavor are deeply rooted in patterns • An important goal of education and training is to transmit patterns from generation to generation. • We will use the analogy of learning to play chess to explore the use of design patterns • In many ways, learning to develop good software is similar to learning to play good chess • Though the consequences of failure are often less dramatic

  7. Becoming a Chess Master • First learn rules and physical requirements • e.g., names of the pieces, legal movements, chess board geometry and orientation, etc. • Then learn principles • e.g., relative value of certain pieces, strategic value of center squares, power of a thread, etc. • Study the games of other masters • These games contain patterns that must be understood, memorized, and applied repeatedly • There are thousands upon thousands of these patterns

  8. Becoming a Master Software Designer • First learn rules and physical requirements • e.g., the algorithms, data structures, software methods and techniques, analysis guidelines , etc. • Then learn principles of software engineering • e.g., modularity, information-hiding, OO analysis, design, and programming, etc. • Study the designs of other masters • These designs contain patterns that must be understood, memorized, and applied repeatedly • There are thousands upon thousands of these patterns

  9. Design Patterns • Design Patterns represent solutions to problems that arise when developing software within a particular context • Patterns == problem/solution pairs in a context • Design Patterns capture the static and dynamic structure and collaboration among key participants in software designs • Design patterns are particularly useful for articulating how and why to solve non-functional forces • Design Patterns facilitate reuse of successful software architecture and design

  10. Abstract Factory Pattern’s Name: Design Problem: Solution: Consequences: A Design Pattern Has Four Essential Elements (1) • Pattern’s Name • A handle • Part of Design Vocabulary • Makes it easier to think about design and to communicate them and their trade-offs to others • Finding good names is hard • Design Problem • Describes when to apply the pattern • Explains the problem and its context • Might describe a class or object structures that are symptomatic of an inflexible design • Might describe assumptions or a list of conditions before applying the pattern Design Pattern’s Description Form

  11. Abstract Factory Pattern’s Name: Design Problem: Solution: Consequences: Design pattern descriptions are often independent of programming languages or implementation details A Design Pattern Has Four Essential Elements (2) • Solution • Describes the elements that make up the design, their relationships, responsibilities, and collaborations • Doesn’t describe a particular concrete design because a pattern is like a template that can be applied in many different situations • Consequences • The result and trade-offs of applying the pattern. • Critical for evaluating design alternatives and understanding the cost and the benefits of applying the pattern • Includes the pattern’s impact on a system’s flexibility, extensibility, or portability. Design Pattern’s Description Form

  12. Design Patterns Catalog Design Pattern Space • Creational Patterns • Deal with initializing and configuring classes and objects • Structural Patterns • Deal with decoupling interface and implementation of classes and objects • Behavioral Patterns • Deal with dynamic interactions among societies of classes and objects

  13. Design Patterns Catalog Samples of Creational Patterns • Abstract Factory • Factory for building related objects • Builder • Factory for building complex objects incrementally • Factory Method • Method in a derived class creates associates • Prototype • Factory for cloning new instances from a prototype • Singleton • Factory for a singular (Sole) instance

  14. Design Patterns Catalog Samples of Structural Patterns • Adapter • Translator adapts a server interface for a client • Bridge • Abstraction for binding one of many implementations • Composite • Structure for building recursive aggregations • Decorator • Decorator extends an object transparently • Flyweight • Many fine-grained objects shared efficiently

  15. Design Patterns Catalog Samples of Behavioral Patterns (1) • Chain of Responsibility • Request delegated to the responsible service provider • Command • Request as First-Class object • Mediator • Mediator coordinates interactions between its associates • Memento • Snapshot captures and restores object states privately

  16. Design Patterns Catalog Samples of Behavioral Patterns (2) • Interpreter • Language interpreter for a small grammar • Iterator • Aggregate elements are accessed sequentially • Strategy • Abstraction for selecting one of any algorithms • Observer • Dependents update automatically when a subject changes • State • Object whose behavior depends on its state

  17. The Process of Discovering Patterns • Experience • Do it yourself • Building things and watch yourself as you build them • Watch others doing it • Watch others performing or building things. This is called Protocol Analysis • Catalog what you have done • Teach and learn

  18. The Potential impact of Patterns H U G E

  19. Design Patterns Make Some of the Chaotic Problems Simple. Why? Patterns provide: • A basis for architectural consistency • A higher-level (design) approach for software problems • A higher-level style convention • A teaching vehicle

  20. Why are Design Patterns Important? • Achieving Software Design Reuse • A reusable Base of Experience • A Documentation and Learning Aid • A Target for Refactoring • An Adjunct to Existing Methodologies • Architectural Elements • Delegation and Double Dispatch • Enhancing Communication • Enhancing Maintainability

More Related