Prototype Pattern Using Prototypes Dependency Injection a Brief Aside

Total Page:16

File Type:pdf, Size:1020Kb

Prototype Pattern Using Prototypes Dependency Injection a Brief Aside 10/21/2011 Prototype pattern Every object is itself a factory Each class contains a clone method that creates a copy of the receiver object class Bicyle { Bicycle clone() { ... } } Often, Object is the return type of clone CSE 331 clone is declared in Object Design flaw in Java 1.4 and earlier: the return type may SOFTWARE DESIGN & IMPLEMENTATION not change covariantly in an overridden method DESIGN PATTERNS II That is, the return type could not be made more restrictive This is a problem for achieving true subtyping Autumn 2011 Using prototypes Dependency injection class Race { Change the factory without changing the code with external Bicycle bproto; dependency injection // constructor BicycleFactory f = ((BicycleFactory) DependencyManager.get("BicycleFactory")); Race(Bicycle bproto) { this.bproto = bproto; } Race r = new TourDeFrance(f); Race createRace() { Plus an external file Bicycle bike1 = (Bicycle) bproto.clone(); <service-point id=“BicycleFactory"> Bicycle bike2 = (Bicycle) bproto.clone(); <invoke-factory> ... <construct class=“Bicycle"> } <service>Tricycle</service> } </construct> </invoke-factory> + Change the factory without recompiling Again, we can specify the race and the bicycle separately </service-point> - Harder to understand (for example, new TourDeFrance(new Tricycle()) without changing any Java code the program might call a different factory) A brief aside: call graphs Precision A call graph is a set of pairs describing, for a given program, which units Of course, there’s an easy algorithm to create a not-very-useful static call (usually methods) call other units (usually methods) graph for (m : method) Eclipse, for example, has a Call Hierarchy view (where the Callee for (n : method) Hierarchy option is often best) that is at times useful in programming include <m,n> in call graph {<main,readCatalog(String)>, <readCatalog(String),readCatalog(InputStream)>, A question is precision – how many false positives are included (<A,B> that are …} included to be conservative but that cannot ever be executed)? This is a static call graph – analyze the program and return a call graph And inversion-of-control complicates this further – using the dependency representing all calls that could happen in any possible execution of the injection pattern, for example, creates a static connection between program <client,Tricycle> that would require quite complex analysis to report (A dynamic call graph is one built by executing the program one or more In practice all or almost all inversion-of-control invocations are omitted in static call graphs times and returning all calls that did take place in those executions) Even if a programmer is not using a static call graph, he or she is going through similar reasoning, and can also become confused or required to analyze in more detail in the Static call graphs are generally expected to be “conservative” – face of inversion-of-control – so be thoughtful and careful about this issue! that is, there are no false negatives, meaning that every <A,B> that This fuzzy connection can make it harder to understand and to change a program, can ever be invoked over any execution is included in the call graph although it can also make it easier to change a program – that’s right, it can make it harder and easier to change at the same time UW CSE331 Autumn 2011 UW CSE331 Autumn 2011 1 10/21/2011 Sharing Interning pattern Reuse existing objects instead of creating new ones Interning: only one object with a particular (abstract) value exists at run-time Less space May compare with == instead of equals() Factory method returns an existing object, not a new Permitted only for immutable objects one 1-100 (Street- NumberSet) Flyweight: separate intrinsic and extrinsic state, "Univ. Way" (Street- "Univ. Way" (String) represent them separately, and intern the intrinsic Segment) (String) StreetSegment with interning 1-100 "O2139" (Street- state (String) NumberSet) StreetSegment (Street- Segment) without interning 101-200 101-200 (Street- Implicit representation uses no space (Street- NumberSet) NumberSet) (Street- Segment) (Street- "Univ. Way" Segment) (String) "O2139" (String) "O2139" (String) java.lang.Boolean does not use Interning mechanism the Interning pattern public class Boolean { Maintain a collection of all objects private final boolean value; If an object already appears, return that instead // construct a new Boolean value HashMap<String, String> segnames; // why not public Boolean(boolean value) { // Set<String>? this.value = value; String canonicalName(String n) { } if (segnames.containsKey(n)) { return segnames.get(n); public static Boolean FALSE = new Boolean(false); public static Boolean TRUE = new Boolean(true); } else { // factory method that uses interning segnames.put(n, n); public static valueOf(boolean value) { return n; if (value) { } return TRUE; } } else { Java builds this in for strings: String.intern() return FALSE; } } } Recognition of the problem Structural patterns: Wrappers Javadoc for Boolean constructor A wrapper translates between incompatible interfaces Allocates a Boolean object representing the value argument Wrappers are a thin veneer over an encapsulated class Note: It is rarely appropriate to use this constructor. Unless a new modify the interface instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better extend behavior space and time performance restrict access Josh Bloch (JavaWorld, January 4, 2004) The encapsulated class does most of the work The Boolean type should not have had public constructors. Wrapper Functionality Interface There's really no great advantage to allow multiple trues or Pattern multiple falses, and I've seen programs that produce millions of trues and millions of falses, creating needless work for the Adapter same different garbage collector Decorator different same So, in the case of immutables, I think factory methods are great Proxy same same 2 10/21/2011 Adapter Adapting via subclassing interface Rectangle { class ScaleableRectangle1 extends NonScaleableRectangle Change an interface without // grow or shrink by the given factor implements Rectangle { changing functionality void scale(float factor); ... void scale(float factor) { rename a method float getWidth(); float area(); setWidth(factor * getWidth()); convert units } setHeight(factor * getHeight()); class myClass { implement a method in } terms of another void myMethod(Rectangle r) { ... r.scale(2); ... } } Example } Have the Rectangle class on class NonScaleableRectangle { the top right void setWidth(float width) { ... } void setHeight(float height) { ... } Want to be able to use the // no scale method NonScaleableRectangle ... class on the bottom right, which } is not a Rectangle Adapting via delegation: Subclassing vs. delegation Forwarding requests to another object class ScaleableRectangle2 implements Rectangle { Subclassing NonScaleableRectangle r; ScaleableRectangle2(NonScaleableRectangle r) { automatically gives access to all methods of superclass this.r = r; built into the language (syntax, efficiency) } Delegation void scale(float factor) { permits cleaner removal of methods (compile-time checking) setWidth(factor * r.getWidth()); setHeight(factor * r.getHeight()); wrappers can be added and removed dynamically } objects of arbitrary concrete classes can be wrapped float getWidth() { return r.getWidth(); } multiple wrappers can be composed float circumference() { return r.circumference(); } Some wrappers have qualities of more than one of ... } adapter, decorator, and proxy Decorator Decorator: Bordered windows interface Window { Add functionality without changing the interface // rectangle bounding the window Add to existing methods to do something additional Rectangle bounds(); (while still preserving the previous specification) // draw this on the specified screen Not all subclassing is decoration void draw(Screen s); ... } class WindowImpl implements Window { ... } 3 10/21/2011 Bordered window implementations A decorator can remove functionality class BorderedWindow1 extends WindowImpl { void draw(Screen s) { Remove functionality without changing the interface super.draw(s); Subclassing Example: UnmodifiableList bounds().draw(s); } What does it do about methods like add and put? } class BorderedWindow2 implements Window { Window innerWindow; BorderedWindow2(Window innerWindow) { this.innerWindow = innerWindow; } void draw(Screen s) { Delegation permits innerWindow.draw(s); innerWindow.bounds().draw(s); multiple borders, borders } and/or shading, etc. } Proxy Visitor pattern Visitor encodes a class Node { Same interface and functionality as the wrapped class traversal of a void accept(Visitor v) { Control access to other objects hierarchical data for each child of node { structure child.accept(v); communication: manage network details when using a Nodes – objects in the } remote object hierarchy – accept visitors; visitors visit v.visit(this); locking: serialize access by multiple clients nodes } } security: permit access only if proper credentials n.accept(v) performs a depth-first creation: object might not yet exist (creation is expensive) traversal of the class Visitor { void visit(Node n) { hide latency when creating object structure rooted at n, performing v's // perform work on n avoid work if object is never used operation on each } element of the } structure Sequence of calls to accept and visit Implementing
Recommended publications
  • (GOF) Java Design Patterns Mock Exams
    Gang of Four (GOF) Java Design Patterns Mock Exams http://www.JavaChamp.com Open Certification Plattform Authors: N. Ibrahim, Y. Ibrahim Copyright (c) 2009-2010 Introducing JavaChamp.com Website JavaChamp.com is an Open Certification Platform. What does this mean? JavaChamp is the best place to learn, share, and certify your professional skills. We help you develop yourself in the field of computer science and programming Here are the most significant features offered by JavaChamp: Online Exams Start Online Certification Exams in SCJP, SCEA, EJB, JMS, JPA and more... Top quality mock exams for SCJP, SCEA, EJB, JMS, JPA. Start Express or topic-wise customized exam. * We offer you unlimited free mock exams * Exams cover subjects like SCJP, SCEA, EJB, JMS, JPA,.. * You can take as many exams as you want and at any time and for no charges * Each exam contains 20 multiple choice questions * You can save the exams taken in your exams history * Your exams history saves the exams you took, the scores you got, time took you to finish the exam, date of examination and also saves your answers to the questions for later revision * You can re-take the same exam to monitor your progress * Your exams history helps the system to offer you variant new questions every time you take a new exam, therefore we encourage you to register and maintain an exams history Network Find guidance through the maze, meet Study-Mates, Coaches or Trainees... Studying together is fun, productive and helps you in building your professional network and collecting leads Bookshelf JavaChamp Bookshelf full of PDF eBooks..
    [Show full text]
  • Design Pattern Interview Questions
    DDEESSIIGGNN PPAATTTTEERRNN -- IINNTTEERRVVIIEEWW QQUUEESSTTIIOONNSS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright © tutorialspoint.com Dear readers, these Design Pattern Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Design Pattern. As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer: What are Design Patterns? Design patterns represent the best practices used by experienced object-oriented software developers. Design patterns are solutions to general problems that software developers faced during software development. These solutions were obtained by trial and error by numerous software developers over quite a substantial period of time. What is Gang of Four GOF? In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled Design Patterns - Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development. These authors are collectively known as Gang of Four GOF. Name types of Design Patterns? Design patterns can be classified in three categories: Creational, Structural and Behavioral patterns. Creational Patterns - These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case. Structural Patterns - These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
    [Show full text]
  • Learning Javascript Design Patterns
    Learning JavaScript Design Patterns Addy Osmani Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo Learning JavaScript Design Patterns by Addy Osmani Copyright © 2012 Addy Osmani. All rights reserved. Revision History for the : 2012-05-01 Early release revision 1 See http://oreilly.com/catalog/errata.csp?isbn=9781449331818 for release details. ISBN: 978-1-449-33181-8 1335906805 Table of Contents Preface ..................................................................... ix 1. Introduction ........................................................... 1 2. What is a Pattern? ...................................................... 3 We already use patterns everyday 4 3. 'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three ...................... 7 4. The Structure Of A Design Pattern ......................................... 9 5. Writing Design Patterns ................................................. 11 6. Anti-Patterns ......................................................... 13 7. Categories Of Design Pattern ............................................ 15 Creational Design Patterns 15 Structural Design Patterns 16 Behavioral Design Patterns 16 8. Design Pattern Categorization ........................................... 17 A brief note on classes 17 9. JavaScript Design Patterns .............................................. 21 The Creational Pattern 22 The Constructor Pattern 23 Basic Constructors 23 Constructors With Prototypes 24 The Singleton Pattern 24 The Module Pattern 27 iii Modules 27 Object Literals 27 The Module Pattern
    [Show full text]
  • JAVA CONCURRENCY ONLINE TRAINING – Java2aspire
    JAVA CONCURRENCY, JAVA PROFILING, THREAD POOLING, JAVA 8 Features, MAVEN and DESIGN PATTERNS ONLINE TRAINING By K.Ramesh Curriculum THREAD POOLING Day 01: Executor Framework 20 min Day 01: Java Profiling 10 min Day 01: Executor 10 min Day 01: ExecutorService 10 min Day 01: Executors 15 min Day 02: ThreadPoolExecutor 20 min Day 02: BlockingQueue 10 min Day 02: Callable vs Runnable 15 min Day 02: Future 15 min JAVA CONCURRENCY Day 03: ConcurrentHashMap 30 min Day 03: Producer Consumer 30 min Day 04: CountDownLatch 20 min Day 04: CyclicBarrier 20 min Day 04: Deadlock Condition 20 min Day 05: Race Condition 30 min Day 05: Semaphore 30 min JAVA 8 FEATURES Day 06: Lambda Expressions 40 min Day 06: Functional Interfaces 10 min Day 06: Functional Programming 10 min Day 07: Method References 10 min Day 07: Default Methods 40 min Day 07: Optional 10 min Day 08: Stream API 1 hour MAVEN Day 09: Project Object Model (POM) 20 min Day 09: Project Description 10 min Day 09: Public Repository 10 min Day 09: Dependency Management 10 min Day 09: Build Configuration 10 min Day 10: Installation 15 min Day 10: Dependency Scope 15 min Day 10: Proprietary Dependencies 15 min Day 10: Project Inheritance 15 min Day 11: Maven life cycle 20 min Day 11: Maven Directory Structure 20 min Day 11: Archetypes 20 min Day 12: Applications 1 hour DESIGN PATTERNS Day 13: Factory Pattern 20 min Day 13: Abstract Factory Pattern 10 min Day 13: Single Pattern 20 min Day 13: Prototype Pattern 10 min Day 14: Composite Pattern 10 min Day 14: Facade Pattern 15 min Day 14: DAO
    [Show full text]
  • Design Patterns in Ocaml
    Design Patterns in OCaml Antonio Vicente [email protected] Earl Wagner [email protected] Abstract The GOF Design Patterns book is an important piece of any professional programmer's library. These patterns are generally considered to be an indication of good design and development practices. By giving an implementation of these patterns in OCaml we expected to better understand the importance of OCaml's advanced language features and provide other developers with an implementation of these familiar concepts in order to reduce the effort required to learn this language. As in the case of Smalltalk and Scheme+GLOS, OCaml's higher order features allows for simple elegant implementation of some of the patterns while others were much harder due to the OCaml's restrictive type system. 1 Contents 1 Background and Motivation 3 2 Results and Evaluation 3 3 Lessons Learned and Conclusions 4 4 Creational Patterns 5 4.1 Abstract Factory . 5 4.2 Builder . 6 4.3 Factory Method . 6 4.4 Prototype . 7 4.5 Singleton . 8 5 Structural Patterns 8 5.1 Adapter . 8 5.2 Bridge . 8 5.3 Composite . 8 5.4 Decorator . 9 5.5 Facade . 10 5.6 Flyweight . 10 5.7 Proxy . 10 6 Behavior Patterns 11 6.1 Chain of Responsibility . 11 6.2 Command . 12 6.3 Interpreter . 13 6.4 Iterator . 13 6.5 Mediator . 13 6.6 Memento . 13 6.7 Observer . 13 6.8 State . 14 6.9 Strategy . 15 6.10 Template Method . 15 6.11 Visitor . 15 7 References 18 2 1 Background and Motivation Throughout this course we have seen many examples of methodologies and tools that can be used to reduce the burden of working in a software project.
    [Show full text]
  • A Survey of Design Pattern Based Web Applications
    JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering ©JOT, 2009 Vol. 8, No. 2, March-April 2009 A Survey of Design Pattern Based Web Applications Sridaran R, Campus Head, ICFAI National College, Vellore-632 006 India. Padmavathi G, Professor and Head, Department of Computer Science, Avinashilingam University for Women, Coimbatore-641 043, India. Iyakutti K, Senior Professor, School of Physics, Madurai Kamaraj University, Madurai-625 019, India. Abstract Pattern-based web applications have become popular since they promote reusability and consistency. In few cases, patterns do not produce the desired effect because of lack of experience in applying them. This situation forces one to think of a suitable re- engineering solution for such applications. The objectives of the paper are three fold. It provides a survey of different pattern-based web applications that will be useful for the application designers. It highlights some of the web applications where patterns have been inappropriately handled. A few re-engineering initiatives for such cases are also analyzed. Key Words: Patterns, Web Applications, Re-engineering, Hypermedia, Semantic web, Partitioning. 1 INTRODUCTION Web application designers need to address many challenges during development in order to comply the quality of service requirements including speed, scalability and security. In recent years numerous non-web based applications have been re-written as web based because of the ever growing business needs. These migration activities are much more complicated and time consuming than a new software development. Most of these challenges are with data handling, organizing, or structuring of the web applications.
    [Show full text]
  • Course Title
    "Charting the Course ... ... to Your Success!" JavaScript Advanced Course Summary Description This course will review the basics of JavaScript and provide instruction on advanced topics such as advanced features of JavaScript functions, Object-Oriented programming in JavaScript (Inheritance, encapsulation) with prototypes, using closures, understanding JavaScript promises and advanced best practices. Objectives At the end of this course, students will be able to: Review Learn function expressions/function declarations/immediately executable functions Use JavaScript objects to implement Inheritance and encapsulation Understand JavaScript closures Learn JavaScript promises Discuss how to best use the advanced topics in this course in your JavaScript projects. Topics Basics Review Object-Oriented Programming Function Expressions Error Handling And Debugging Advanced Techniques Audience This course is intended for JavaScript programmers Prerequisites JavaScript introduction Duration Two days Due to the nature of this material, this document refers to numerous hardware and software products by their trade names. References to other companies and their products are for informational purposes only, and all trademarks are the properties of their respective companies. It is not the intent of ProTech Professional Technical Services, Inc. to use any of these names generically "Charting the Course ... ... to Your Success!" JavaScript Advanced Course Outline I. Basics Review IV. Error Handling And Debugging A. Browser Error Reporting II. Object-Oriented Programming B. Internet Explorer A. Understanding Objects C. Firefox B. Types of Properties D. Chrome C. Defining Multiple Properties E. Error Handling D. Reading Property Attributes F. The try-catch Statement E. Object Creation G. Throwing Errors F. The Factory Pattern H. The error Event G. The Constructor Pattern I.
    [Show full text]
  • Creational Patterns
    9. Creational Pattern Venkat Subramaniam CDP-1 Creational Patterns • Abstracts instantiation process • Makes system independent of how its objects are œ created œ composed œ represented • Encapsulates knowledge about which concrete classes the system uses • Hides how instances of these classes are created and put together Venkat Subramaniam CDP-2 Abstract Factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes Venkat Subramaniam CDP-3 Example that would benefit from Abstract Factory ComputerModelA MemoryType A CPUTypeA ModemTypeA BuildComputer(ComputerModelA& comp) { comp.Add(new MemoryTypeA); comp.Add(new CPUTypeA); comp.Add(new ModemTypeA); } What if I want to build a Computer of Model B with Model B Memory,CPU and Modem? Venkat Subramaniam CDP-4 Using Abstract Factory ComputerFactory Client Computer createComputer() createMemory() createCPU() Computer Computer createModem() ModelA ModelB Memory CompFactoryB CompFactoryA createComputer() createComputer() Memory Memory createMemory() createMemory() ModelA ModelB createCPU() createCPU() createModem() createModem() Venkat Subramaniam CDP-5 Using Abstract Factory... BuildComputer(Computer& comp, ComputerFactory& compFactory) { comp.Add(compFactory.createMemory()) ; comp.Add(compFactory.createCPU()); comp.Add(compFactory.createModem()); } Venkat Subramaniam CDP-6 .hen to use Abstract Factory? • Use Abstract Factory when: œ system should be independent of how its products are created, composed and represented œ system should
    [Show full text]
  • Java Design Patterns I
    Java Design Patterns i Java Design Patterns Java Design Patterns ii Contents 1 Introduction to Design Patterns 1 1.1 Introduction......................................................1 1.2 What are Design Patterns...............................................1 1.3 Why use them.....................................................2 1.4 How to select and use one...............................................2 1.5 Categorization of patterns...............................................3 1.5.1 Creational patterns..............................................3 1.5.2 Structural patterns..............................................3 1.5.3 Behavior patterns...............................................3 2 Adapter Design Pattern 5 2.1 Adapter Pattern....................................................5 2.2 An Adapter to rescue.................................................6 2.3 Solution to the problem................................................7 2.4 Class Adapter..................................................... 11 2.5 When to use Adapter Pattern............................................. 12 2.6 Download the Source Code.............................................. 12 3 Facade Design Pattern 13 3.1 Introduction...................................................... 13 3.2 What is the Facade Pattern.............................................. 13 3.3 Solution to the problem................................................ 14 3.4 Use of the Facade Pattern............................................... 16 3.5 Download the Source Code.............................................
    [Show full text]
  • Table of Contents
    Table of Contents ± -—T^jTp^om Object-Oriented to Functional Programming 5 Chajava- an introduction 5 java programming paradigms 6 CO imperative programming CD Real-life imperative example Object-oriented paradigm 7 Objects and classes 7 Encapsulation 7 Abstraction 8 Inheritance 8 Polymorphism 9 Declarative programming 10 Functional programming 11 Working with collections versus working with streams 11 An introduction to Unified Modeling Language 12 Class relations 14 Generalization 15 Realization 15 Dependency 16 Association 16 Aggregation 16 Composition 17 Design patterns and principles 17 Single responsibility principle 18 Open/closed principle 20 Liskov Substitution Principle 20 Interface Segregation Principle 22 Dependency inversion principle 23 Summary 24 Chapter 2: Creational Patterns 27 Singleton pattern 27 Synchronized singletons 29 Synchronized singleton with double-checked locking mechanism 30 Lock-free thread-safe singleton 30 tu * y and lazy loacling 31 i he factory pattern 31 Simple factory pattern 32 Table of Contents Static factory 33 Simple factory with class registration using reflection 34 Simple factory with class registration using Product.newlnstance 35 Factory method pattern 36 Anonymous concrete factory 38 Abstract factory 38 Simple factory versus factory method versus abstract factory 40 Builder pattern 40 Car builder example 41 Simplified builder pattern 43 Anonymous builders with method chaining 44 Prototype pattern 45 Shallow clone versus deep clone Object pool pattern Summary аэоэсБ Chapter 3: Behavioral Patterns
    [Show full text]
  • Object-Oriented Design Patterns
    Object-Oriented Design Patterns David Janzen EECS 816 Object-Oriented Software Development University of Kansas Outline • Introduction – Design Patterns Overview – Strategy as an Early Example – Motivation for Creating and Using Design Patterns – History of Design Patterns • Gang of Four (GoF) Patterns – Creational Patterns – Structural Patterns – Behavioral Patterns Copyright © 2006 by David S. 2 Janzen. All rights reserved. What are Design Patterns? • In its simplest form, a pattern is a solution to a recurring problem in a given context • Patterns are not created, but discovered or identified • Some patterns will be familiar? – If you’ve been designing and programming for long, you’ve probably seen some of the patterns we will discuss – If you use Java Foundation Classes (Swing), Copyright © 2006 by David S. 3 you have certaJiannzleyn. Aulls rieghdts rsesoervmed.e design patterns Design Patterns Definition1 • Each pattern is a three-part rule, which expresses a relation between – a certain context, – a certain system of forces which occurs repeatedly in that context, and – a certain software configuration which allows these forces to resolve themselves 1. Dick Gabriel, http://hillside.net/patterns/definition.html Copyright © 2006 by David S. 4 Janzen. All rights reserved. A Good Pattern1 • Solves a problem: – Patterns capture solutions, not just abstract principles or strategies. • Is a proven concept: – Patterns capture solutions with a track record, not theories or speculation 1. James O. Coplien, http://hillside.net/patterns/definition.html Copyright © 2006 by David S. 5 Janzen. All rights reserved. A Good Pattern • The solution isn't obvious: – Many problem-solving techniques (such as software design paradigms or methods) try to derive solutions from first principles.
    [Show full text]
  • Non-Software Examples of Software Design Patterns Автор: Michael Duell
    Non-Software Examples of Software Design Patterns Автор: Michael Duell. Хорошая, хоть и старая (97 год) статья в которой приведены примеры применения паттернов в вещах, которые не имеют отношения к разработке. Такой подход отлично иллюстрирует паттерны и делает их более доступными для понимания. Например отлично показан паттерн Фасад: интерфейсы офисных устройств можно сильно упростить с помощью секретарши. Или например паттерн Бридж, который показан на примере выключателя которым можно управлять лампочкой, вентилятором или любым другим прибором. Non-Software Examples of Software Design Patterns by Michael Duell Abstract Software design patterns have roots in the architectural patterns of Christopher Alexander, and in the object movement. According to Alexander, patterns repeat themselves, since they are a generic solution to a given system of forces. The object movement looks to the real world for insights into modeling software relationships. With these dual roots, it seems reasonable that software design patterns should be repeated in real world objects. This paper presents a real world, non software instance of each design pattern from the book, Design Patterns - Elements of Reusable Object-Oriented Software [13]. The paper also discusses the implications of non-software examples on the communicative power of a pattern language, and on design pattern training. 1. Introduction Within the software industry, a growing community of patterns proponents exists. The roots of the patterns movement are found in the writings of architect Christopher Alexander, who describes a pattern as a generic solution to a given system of forces in the world [1]. Alexander's patterns can be observed in everyday structures. Each pattern in A Pattern Language[2] includes a picture of an archetypal example of the pattern.
    [Show full text]