Wiley & Sons, Inc

Total Page:16

File Type:pdf, Size:1020Kb

Wiley & Sons, Inc Y L F M A E T Team-Fly® JavaJava™ EnterpriseEnterprise Design Patterns Patterns in JavaTM, Volume 3 MARK GRAND MARK GRAND John Wiley & Sons, Inc. New York ● ChichesterJohn● Weinheim Wiley &● Sons,Brisbane Inc. ● Singapore ● Toronto New York ● Chichester ● Weinheim ● Brisbane ● Singapore ● Toronto Publisher: Robert Ipsen Editor: Theresa Hudson Developmental Editor: Kathryn A. Malm Managing Editor: Angela Smith New Media Editor: Brian Snapp Text Design & Composition: Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, how- ever, should contact the appropriate companies for more complete information regarding trademarks and registration. This book is printed on acid-free paper. ●∞ Copyright © 2002 by Mark Grand. All rights reserved. Published by John Wiley & Sons, Inc., New York Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be sought. Library of Congress Cataloging-in-Publication Data: Grand, Mark. Java Enterprise design patterns / Mark Grand. p. cm. ISBN 0-471-33315-8 (pbk.: alk. paper) 1. Java (Computer program language) 2. Web servers. 3. Object- oriented programming (Computer science) I. Title. QA76.73.J38 G72 2001 005. 13'3—dc21 2001045611 Printed in the United States of America. 10987654321 CONTENTS Acknowledgments vii About the Author viii Chapter 1 Introduction to Software Patterns 1 Description of Patterns 2 Pattern Name 3 Synopsis 3 Context 3 Forces 3 Solution 4 Consequences 4 Implementation 4 Known Uses 4 Code Example 4 Related Patterns 4 A Very Brief History of Patterns 5 Organization of This Book 5 iv ■ CONTENTS Chapter 2 Overview of UML 7 Class Diagram 8 Collaboration Diagram 18 Statechart Diagram 26 Deployment Diagram 28 Chapter 3 The Software Life Cycle 29 Chapter 4 Transaction Patterns 33 Acid Transaction 37 Composite Transaction 55 Two Phase Commit 65 Audit Trail 75 Chapter 5 Distributed Architecture Patterns 81 Shared Object 83 Object Request Broker 89 Object Replication 99 Redundant Independent Objects 109 Prompt Repair 115 Mobile Agent 119 Demilitarized Zone 129 Process Pairs 133 Chapter 6 Distributed Computing Patterns 137 Object Identifier 139 Registry 149 Protection Proxy 157 Publish-Subscribe 175 Retransmission 187 Mailbox 195 Heavyweight/Lightweight 203 Heartbeat 209 Connection Multiplexing 229 Chapter 7 Concurrency Patterns 275 Session Object 277 Lock File 285 Static Locking Order 291 Optimistic Concurrency 297 Thread Pool 303 Ephemeral Cache Item 325 Transaction State Stack 337 Contents ■ v Chapter 8 Temporal Patterns 347 Time Server 349 Versioned Object 355 Temporal Property 373 Chapter 9 Database Patterns 387 Persistence Layer 389 CRUD 407 Stale Object 413 Type Conversion 423 IsDirty 431 Lazy Retrieval 439 Appendix A Persistence Framework 445 Bibliography 475 Index 477 ACKNOWLEDGMENTS This book would not have been possible without the inspiration, encour- agement and assistance of others. I want to thank Brad Appleton for his diligent reviews and concern with form. Wolfgang W. Keller provided extensive feedback on the transaction patterns chapter. Frank Sauer provided excellent feedback on the database patterns chapter. I also want to thank the members of the pattern discussion group at University of Illinois, Champaign-Urbana, for their invaluable comments on my manuscript: Joe Yoder, Brian Foote, Hiroaki Nakamura, Roger Whitney, Ralph Johnson, Brian Marick, Wanghong Yuan, Paul Rubel, Frederico Balaguer, Alejandra Garrido, Don Roberts, Zhijiang “John” Han, Weerasak Witthawuskul, Peter Hatch, Dragos Malolescu, and Les Tyrrell. Last, but not least, I would like to thank my wife Nicole for her sup- port and encouragement through the most difficult of times. This book could not have been finished without her understanding and patience. ABOUT THE AUTHOR Y L F M Mark Grand is a consultant specializingA in distributed systems, object- oriented design, and Java.E He is currently working on an open source framework for gluing components and programs into an application. Mark Grand is theT author of a series of books titled Patterns in Java. He is a consultant who specializes in Distributed Systems, Object Oriented Design, and Java. He was the architect of the first commercial B2B e-commerce product for the Internet. Team-Fly® CHAPTER 1 Introduction to Software Patterns Software patterns are reusable solutions to recurring problems that occur during software development. For purposes in this book, we refer to soft- ware patterns simply as patterns. What makes a bright, experienced programmer so much more produc- tive than a bright but inexperienced programmer? Experience. Experience gives programmers wisdom. As programmers gain experience, they recog- nize the similarity between new problems and those problems that they have solved before. With even more experience, they recognize that the solutions for similar problems follow recurring patterns. Experienced programmers recognize the situations where these patterns apply and quickly draw on existing solutions without having to stop, analyze the problems, and then pose possible strategies. When a programmer discovers a pattern, it’s just an insight. In most cases, to go from a nonverbalized insight to a well-thought-out idea that the programmer can clearly articulate is surprisingly difficult. It’s also an extremely valuable step. When we understand a pattern well enough to put it into words, we are able to intelligently combine it with other patterns. More important, once put into words, a pattern can be used in discussions among programmers who know the pattern. That allows programmers to more effectively collaborate and combine their wisdom. It can also help to 1 2 ■ CHAPTER ONE avoid the situation where programmers argue over various solutions to a problem only to find out later that they were really thinking of the same solution but expressing it in different ways. Putting a pattern into words has an additional benefit for less experi- enced programmers who have not yet discovered the pattern. Once a pat- tern has been put into words, more experienced programmers can teach it to programmers who are new to the pattern. This book provides experienced programmers with a common vocab- ulary to discuss patterns. It also allows programmers who have not yet dis- covered a pattern to learn about the pattern. Though this book includes a substantial breadth of patterns, addi- tional patterns did not make it into this book. You, dear reader, may dis- cover some of these patterns for yourself. Some patterns you discover may be highly specialized and of interest to only a small number of people. Other patterns may be of very broad interest and worthy of inclusion in a future volume of this book. If you wish to communicate such a pattern to me, my e-mail is [email protected]. The patterns cataloged in this book convey constructive ways of orga- nizing parts of the software development cycle. Other patterns that recur in programs are not constructive. These types of patterns are called AntiPatterns. Because AntiPatterns can cancel out the benefits of patterns, this book does not attempt to catalog them. Description of Patterns Patterns are usually described using a format that includes the following information: • A description of the problem that includes a concrete example and a solution specific to the concrete problem • A summary of the forces that lead to the formulation of a general solution • A general solution • The consequences, good and bad, of using the given solution to solve a problem • A list of related patterns Pattern books differ in how they document patterns. The format used in this book varies depending on which phase of the software life cycle the pattern addresses. The patterns in this book are related to a few different phases of the software life cycle. The pattern descriptions are organized into the section headings described here. Because the nature of the pat- terns varies, not every heading is used in every pattern. Introduction to Software Patterns ■ 3 Pattern Name The Pattern Name section consists of the name of the pattern and a bibliogra- phy reference that indicates where the pattern originated. Most patterns don’t have any additional text under this heading. For those that do, this section contains information about the derivation or general nature of the pattern. The bibliography reference indicates where the ideas in the pattern were first written in the form of a pattern. Because patterns are based on established practices, in many cases there are other sources of the ideas in the pattern other than the bibliography reference. Usually, the author of a pattern is not the first person to discover the ideas that underlie the pat- tern. In particular, I do not claim to be the first person to discover the ideas presented in this book. Those patterns with a bibliographic reference to this book merely indicate that I know of no other place where that par- ticular set of ideas has been documented as a pattern.
Recommended publications
  • Srm University Faculty of Engineering and Technology
    SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SWE COURSE PLAN Course Code : CS0373 Course Title : DESIGN PATTERNS Semester : VII Course Time : July – December 2014 C Day Hour Timing Day 1 6 2.20 to 3.10 Day 3 5 1.30 to 2.20 Day 5 3,5 10.35 to 11.25 and 1.30 to 2.20 Location : S.R.M.E.C – University Building (12 th Floor) Faculty Details Sec. Name Office Office hour Mail id Ms. Cinza Susan University Monday to Friday [email protected] Abraham Building Required Text Books: TEXT BOOK 1Alan Shalloway, James Trott, “Design Patterns Explained: A New Perspective on Object- Oriented Design”,Addison-Wesley, 2005 2. Joshua Kerievsky, “Refactoring to Patterns”, Addison-Wesley, 2004 REFERENCE BOOKS 1. Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, “Design Patterns : Elements of Reusable Object-Oriented Software”, Addison-Wesley, 1995. 2. Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates, “Head First Design Patterns”, O'Reilly Media, Inc., 2004. 3. Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts.“Refactoring: Improving the Design of Existing Code”, Addison-Wesley, 1999. Prerequisite : Software Engineering Principles Software Architecture Software Design Objectives This course introduces the students to 1. Understand and be able to apply incremental/iterative development 2. Understand common design patterns 3. Be able to identify appropriate design patterns for various problems 4. Be able to refactor poorly designed program by using appropriate design patterns. Assessment Details Cycle Test 1 : 10 Marks Cyle Test II : 10 Marks Model Exam : 20 Marks Surprise Test : 5 Marks Attendance : 5 Marks Test Schedule S.No.
    [Show full text]
  • Design Patterns. Introduction
    DESIGN PATTERNS COURSE 1 OGANIZATION q Course q Each week 2 hours, Room 050A q Laboratory q Each odd/even school week, Room 050A q Presence q Course: minimum 50% q Laboratory: minimum 50% q Grade q Written exam 50% q Course activity 1%+ laboratory activity 24% q Presentation of a pattern 10% q Project 15% ORGANIZATION q Course & laboratories q available at http://staff.fmi.uvt.ro/~flavia.micota/ q Contact q e-mail: [email protected] q cab. 046B q Classroom q 1rcgcs COURSE CONTENT q Design patterns q Creational q Structural q Behavioral q Refactoring q Anti-patterns q Students presentations of a pattern WAY YOU CHOSE THIS COURSE? WAY YOU CHOSE THIS COURSE? q Some reasons from http://www.ida.liu.se/~chrke55/courses/SWE/bunus/DP01_1sli de.pdf q I could get some easy points. q Everybody is talking about so it must to be cool. q If I master this I can added it to my CV. q Increase my salary at the company. q Applying patterns is easier than thinking q A great place to pick up ideas to plagiarize. DESIGN CHALLENGES q Designing software with good modularity is hard! q Designs often emerge from a lot of trial and error q Are there solutions to common recurring problems? q A Design Pattern is a Tried and True Solution To a Common Problem q Basically, people, who have done this a lot, are making a suggestion! SOURCE CODE QUALITY q What characteristics should be respected in order to deliver a quality sorce code for a project? SOURCE CODE QUALITY q What characteristics should be respected in order to deliver a quality sorce code for a project? q Easy to read/understood – clear q Easy to modify – structured q Easy to reuse q Simple (complexity) q Easy to test q Implements patterns for standard problems SOURCE CODE QUALITY q What influence source code quality? q Development time q Costs q Programmer experience q Programmer abilities q Specifications clarity q Solution complexity q Requirements change rate, team, … PATTERNS q A pattern is a recurring solution to a standard problem, in a context.
    [Show full text]
  • Designpatternsphp Documentation Release 1.0
    DesignPatternsPHP Documentation Release 1.0 Dominik Liebler and contributors Jul 18, 2021 Contents 1 Patterns 3 1.1 Creational................................................3 1.1.1 Abstract Factory........................................3 1.1.2 Builder.............................................8 1.1.3 Factory Method......................................... 13 1.1.4 Pool............................................... 18 1.1.5 Prototype............................................ 21 1.1.6 Simple Factory......................................... 24 1.1.7 Singleton............................................ 26 1.1.8 Static Factory.......................................... 28 1.2 Structural................................................. 30 1.2.1 Adapter / Wrapper....................................... 31 1.2.2 Bridge.............................................. 35 1.2.3 Composite............................................ 39 1.2.4 Data Mapper.......................................... 42 1.2.5 Decorator............................................ 46 1.2.6 Dependency Injection...................................... 50 1.2.7 Facade.............................................. 53 1.2.8 Fluent Interface......................................... 56 1.2.9 Flyweight............................................ 59 1.2.10 Proxy.............................................. 62 1.2.11 Registry............................................. 66 1.3 Behavioral................................................ 69 1.3.1 Chain Of Responsibilities...................................
    [Show full text]
  • Developing with Pojos: Faster and Easier 3 Chapter 2 ■ J2EE Design Decisions 31
    FROM OUR PEER REVIEW ... “Chris Richardson targets critical design issues for lightweight Java enterprise applications using POJOs with fantastic in-depth exam- ples. This book extends Martin Fowler’s great book, Enterprise Architecture Patterns, as well as the more recent Domain-Driven Design by Eric Evans, by providing practical design guidance and useful examples. It also addresses the architecture and design issues asso- ciated with Spring and Hibernate development, whereas Man- ning’s companion ‘in Action’ books focus primarily on the Spring and Hibernate technologies. “This is a powerful book for architects, senior developers, and consultants. It uniquely combines best practices and design wisdom to integrate domain-driven design and test-driven development for object-oriented Java enterprise applications using lightweight Spring, Hibernate, and JDO technologies. “The table of contents reflects the important topics that most architects and enterprise developers face every day. There is signifi- cant need for a book like this, which shows how to address many common and complex design issues with real-world examples. The content in this book is unique and not really available elsewhere.” DOUG WARREN Software Architect Countrywide Financial “POJOs in Action fills a void: the need for a practical explanation of the techniques used at various levels for the successful building of J2EE projects. This book can be compared with the less enterprise- oriented and more abstract J2EE Development without EJB by Rod Johnson, but Richardson offers a step-by-step guide to a successful J2EE project. The explanations of the various alternatives available for each step provide the main thrust of this book.
    [Show full text]
  • Lecture 26: Creational Patterns
    Creational Patterns CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 26 — 11/29/2012 © Kenneth M. Anderson, 2012 1 Goals of the Lecture • Cover material from Chapters 20-22 of the Textbook • Lessons from Design Patterns: Factories • Singleton Pattern • Object Pool Pattern • Also discuss • Builder Pattern • Lazy Instantiation © Kenneth M. Anderson, 2012 2 Pattern Classification • The Gang of Four classified patterns in three ways • The behavioral patterns are used to manage variation in behaviors (think Strategy pattern) • The structural patterns are useful to integrate existing code into new object-oriented designs (think Bridge) • The creational patterns are used to create objects • Abstract Factory, Builder, Factory Method, Prototype & Singleton © Kenneth M. Anderson, 2012 3 Factories & Their Role in OO Design • It is important to manage the creation of objects • Code that mixes object creation with the use of objects can become quickly non-cohesive • A system may have to deal with a variety of different contexts • with each context requiring a different set of objects • In design patterns, the context determines which concrete implementations need to be present © Kenneth M. Anderson, 2012 4 Factories & Their Role in OO Design • The code to determine the current context, and thus which objects to instantiate, can become complex • with many different conditional statements • If you mix this type of code with the use of the instantiated objects, your code becomes cluttered • often the use scenarios can happen in a few lines of code • if combined with creational code, the operational code gets buried behind the creational code © Kenneth M. Anderson, 2012 5 Factories provide Cohesion • The use of factories can address these issues • The conditional code can be hidden within them • pass in the parameters associated with the current context • and get back the objects you need for the situation • Then use those objects to get your work done • Factories concern themselves just with creation, letting your code focus on other things © Kenneth M.
    [Show full text]
  • 8 Lecture 1 Introduction to the Class Diagram
    ECE 573 1st Edition Exam # 1 Study Guide Lectures: 1 - 8 Lecture 1 Introduction to the Class diagram, Inheritance and Association Class Diagram The final code was supplemented with a diagram describing the relationships between classes. The intermediate classes of the code are related by objects. This is what is represented in a class diagram. The Class diagram basically consists of “a Class name”, “attributes” and “operation”. Given this basic graphical notation, it is possible to show the following kinds of relationships between classes: Inheritance Association Encapsulation Inheritance It is denoted using open triangle between Superclass and its Subclass. The triangle “points" to the superclass, and extends to the subclass (es). Inheritance fulfills the IS-A definitions. A derived class can be treated like a base class object under all circumstances. Association General binary relationships between classes. It is commonly represented as direct or indirect references between classes. Associations are shown by a line in the class diagram, with optional role names and multiplicities. Multiplicities can be i) I..u closed ii) I singleton range iii) 0..* entire nonnegative integer. An association may also be specialized by a particular class. This Association class may provide more attributes to describe the association. Encapsulations Encapsulation is a special kind of association, which is denoted using a diamond and extending line. There are two kinds of encapsulation i.e. Aggregation and Composition. Aggregation is a special form of association representing has-a and part-whole relationship. Distinguishes the whole (aggregate class) from its parts (component class). No relationship in the lifetime of the aggregate and the components (can exist separately).
    [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 Paradigm/Programming
    an object is an instantiation from a class, e.g., you have a pet cat, who's Object Oriented Paradigm name is Garfield, then Garfield is a object (of the class cat) to invoke an method, simply do obj.method( ) or obj->method( ), the Ming- Hwa Wang, Ph.D. former is object reference syntax, and the latter is pointer syntax Department of Computer Engineering Santa Clara University Relationships a-kind-of relationship: a subclass inherits and adds more attributes Object Oriented Paradigm/Programming (OOP) and/or methods from its super class to become somewhat "specialized" similar to Lego, which kids build new toys from assembling the existing is-a relationship: an object of a subclass is an object of its super class construction blocks of different shapes part-of relationship: OOP - doing programs by reusing (composing/inheriting) objects has-a relationship: (instantiated from classes) as much as possible, and only writing code when no exiting objects can be applied Reusability inheritance Two Fundamental Principles for OOP a sub/child/derived/extended class can inherit all properties from its generalization or reusability: the classes designed should target to super/parent/base/original class, with or without reusability, i.e., it should very generic and can be applied to lots of modification/override or addition situations/applications without much efforts; reusability comes from single inheritance and multiple inheritance (watch out naming inheritance and/or composition conflicts) encapsulation or information hiding: we can hide detailed or composition implementation specific information away from the users/programmers, so changing implementation using the same interfaces will not need Abstract or Virtual Classes modifying the application code only used as a super class for other classes, only specified but not fully defined, and can't be instantiated OOP Language vs.
    [Show full text]
  • [ Team Lib ] Crawford and Kaplan's J2EE Design Patterns Approaches
    [ Team LiB ] • Table of Contents • Index • Reviews • Reader Reviews • Errata J2EE Design Patterns By William Crawford, Jonathan Kaplan Publisher: O'Reilly Pub Date: September 2003 ISBN: 0-596-00427-3 Pages: 368 Crawford and Kaplan's J2EE Design Patterns approaches the subject in a unique, highly practical and pragmatic way. Rather than simply present another catalog of design patterns, the authors broaden the scope by discussing ways to choose design patterns when building an enterprise application from scratch, looking closely at the real world tradeoffs that Java developers must weigh when architecting their applications. Then they go on to show how to apply the patterns when writing realworld software. They also extend design patterns into areas not covered in other books, presenting original patterns for data modeling, transaction / process modeling, and interoperability. [ Team LiB ] [ Team LiB ] • Table of Contents • Index • Reviews • Reader Reviews • Errata J2EE Design Patterns By William Crawford, Jonathan Kaplan Publisher: O'Reilly Pub Date: September 2003 ISBN: 0-596-00427-3 Pages: 368 Copyright Preface Audience Organization of This Book For Further Reading Conventions Used in This Book Comments and Questions Acknowledgments Chapter 1. Java Enterprise Design Section 1.1. Design Patterns Section 1.2. J2EE Section 1.3. Application Tiers Section 1.4. Core Development Concepts Section 1.5. Looking Ahead Chapter 2. The Unified Modeling Language Section 2.1. Origins of UML Section 2.2. The Magnificent Seven Section 2.3. UML and Software Development Lifecycles Section 2.4. Use Case Diagrams Section 2.5. Class Diagrams Section 2.6. Interaction Diagrams Section 2.7.
    [Show full text]
  • Critical Resource Concurrency Pattern in C++
    ApriorIT Inc. Implementation of Critical Resource Concurrency Pattern in C++ Implementation of Critical Resource Concurrency Pattern in C++ The article is written by Vladimir Frolov, system developer of ApriorIT. The topic area of concurrency patterns is poorly covered in literature, so this text is called to fill a gap, at least partly. Many of those who have ever used Critical Section object for synchronization between threads were applying it together with Auto Critical Section object. Indeed, Auto Critical Section is a powerful synchronization object which use has a set of advantages. The code containing Auto Critical Section for Critical Section management turns safe, more readable and structured when compared with the code directly working with Critical Section. Moreover, Auto Critical Section has trivial implementation. Regarding Auto Critical Section object one might say that it wraps in Critical Section the scope in which it is being created. However, whether Auto Critical Section used or not, there is still a series of problems relating to Critical Section object: • the Critical Section and resource which it protects are being created separately and can potentially have different lifetime. • the code which uses the resource must know that access to it is synchronized by critical section. Both these problems are of little importance if the critical section is used for creation of a thread- safe class. In that case the critical section is being created as data member and about it should be aware only function members of the given class while creating an Auto Critical Section object on call. However, a problem appears if it is necessary to provide access to a resource or class object which doesn't make any attempts at synchronization from within.
    [Show full text]
  • IC Coder's Club Design Patterns (In C++)
    Andrew W. Rose Simple exercise You have been tasked to move this pile from A to B Simple exercise You have been tasked to move this pile from A to B You have three resources available to you: a) Bare hands b) A stack of timber c) A horse and cart Simple exercise You have been tasked to move this pile from A to B You have three resources available to you: a) Bare hands b) A stack of timber c) A horse and cart How do you achieve the task in the quickest, least-painful way, which won’t leave you up-to-your-neck in the produce you are moving, nor smelling of it? Software analogy a) Bare hands b) A stack of timber c) A horse and cart Software analogy a) Bare hands b) A stack of timber c) A horse and cart Do a task manually Software analogy a) Bare hands b) A stack of timber c) A horse and cart Design Do a task the tools manually yourself Software analogy a) Bare hands b) A stack of timber c) A horse and cart Benefit from Design Do a task someone the tools manually else’s yourself hard work Software analogy a) Bare hands b) A stack of timber c) A horse and cart Benefit from someone else’s This is the purpose of design patterns! hard work Motivation I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important: Bad programmers worry about the code; good programmers worry about data structures and their relationships.
    [Show full text]
  • 60 Years of Mastering Concurrent Computing Through Sequential Thinking Sergio Rajsbaum, Michel Raynal
    60 Years of Mastering Concurrent Computing through Sequential Thinking Sergio Rajsbaum, Michel Raynal To cite this version: Sergio Rajsbaum, Michel Raynal. 60 Years of Mastering Concurrent Computing through Sequential Thinking. ACM SIGACT News, Association for Computing Machinery (ACM), 2020, 51 (2), pp.59-88. 10.1145/3406678.3406690. hal-03162635 HAL Id: hal-03162635 https://hal.archives-ouvertes.fr/hal-03162635 Submitted on 17 Jun 2021 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. 60 Years of Mastering Concurrent Computing through Sequential Thinking ∗ Sergio Rajsbaumy, Michel Raynal?;◦ yInstituto de Matemáticas, UNAM, Mexico ?Univ Rennes IRISA, 35042 Rennes, France ◦Department of Computing, Hong Kong Polytechnic University [email protected] [email protected] Abstract Modern computing systems are highly concurrent. Threads run concurrently in shared-memory multi-core systems, and programs run in different servers communicating by sending messages to each other. Concurrent programming is hard because it requires to cope with many possible, unpre- dictable behaviors of the processes, and the communication media. The article argues that right from the start in 1960’s, the main way of dealing with concurrency has been by reduction to sequential reasoning.
    [Show full text]