Experience Using Design Patterns to Develop Reuseable Object-Oriented Communication Software

Experience Using Design Patterns to Develop Reuseable Object-Oriented Communication Software

Experience Using Design Patterns to Develop Reuseable Object-Oriented Communication Software Douglas C. Schmidt [email protected] http://www.cs.wustl.edu/schmidt/ Department of Computer Science Washington University, St. Louis 63130 (TEL) 314-935-7538, (FAX) 314-935-7302 This article will appear in the Communications of the ACM arise when building software in domains like business data Special Issue on Object-Oriented Experiences, Vol. 38, No. processing, telecommunications, graphical user interfaces, 10, October, 1995. Section 2 illustrates an example pattern databases, and distributed communication software. Patterns description that is a synopsis of material from [1]. Section 3 aid the development of reusable components and frameworks is new material that summarizes the lessons learned while by expressing the structure and collaboration of participants applying a design pattern-based reuse strategy on production in a software architecture at a level higher than (1) source large-scale distributed systems being developed on several code or (2) object-oriented design models that focus on in- commercial systems. dividual objects and classes. Thus, patterns facilitate reuse of software architecture, even when other forms of reuse are infeasible (e.g., due to fundamental differences in operating Abstract system features [3]). Design patterns help to enhance software qualityby address- This article describes how design patterns are being ap- ing fundamental challenges in large-scale system develop- plied on a number of large-scale commercial distributed sys- ment. These challenges include communication of archi- tems. Patterns have been used on these projects to enable tectural knowledge among developers, accommodating new widespread reuse of communication software architectures, design paradigms or architectural styles, and avoiding de- developer expertise, and object-oriented framework compo- velopment traps and pitfalls that are usually learned only nents. These systems include the system control segment by experience. This article describes lessons learned from for the Motorola Iridium global personal communications applying a design pattern-based reuse strategy to develop system [4]; a family of network monitoring applications for object-oriented communication software frameworks for sev- Ericsson telecommunication switches [3]; and a system for eral production distributed systems. Design patterns are in transporting multi-megabyte medical images over high-speed danger of becoming yet another buzzword. This article at- ATM networks [5] being developed at BJC health system and tempts to replacethehypewith insights and recommendations Washington University School of Medicine (BJC/WUSM). gained from several years of experience. This article also presents ways to avoid common traps and pitfalls of applying design patterns in large-scale software development processes. 1 Introduction The remainder of this article is organized as follows: Sec- tion 2 illustrates a design pattern that appears frequently in Despite dramatic increases in network and host performance event-driven communication software frameworks; Section 3 it remains dif®cult to design, implement, and reuse commu- summarizes our experiences (both positive and negative) ap- nication software for complex distributed systems. Exam- plying a design pattern-based reuse strategy in several large- ples of these systems include global personal communication scale commercial distributed systems; and Section 4 outlines systems, network management platforms, enterprise medical pattern-related topics that will be the focus of considerable imaging systems, and real-time market data monitoring and research activities in the next few years. analysis systems. In addition, it is often hard to directly reuse existing algorithms, detailed designs, interfaces, or im- plementations in these systems due to the growing hetero- 2 Example Design Pattern: the Reactor geneity of hardware/software architectures and diversity of operating system platforms. This section describes the Reactor pattern. This pattern was Design patterns [2] are a promising technique for achiev- identi®ed while developing reusable event-driven commu- ing widespread reuse of software architectures. Design pat- nication software at Ericsson, Motorola, and BJC/WUSM. terns capture the static and dynamic structures and collabora- Portions of the material below was culled from documenta- tions of components in successful solutions to problems that tion used on these projects. 1 Design patterns have been described using several formats threading may not be available on an OS platform. [2, 6, 7]. The format used below is based on the work of Often, a more convenient and portable way to develop Gamma et al. [2]; it contains the following parts: event-driven servers is to use the Reactor pattern.TheRe- actor pattern manages a single-threaded event loop that per- The intent of the pattern forms event demultiplexing and event handler dispatching in The design forces that motivate the pattern response to events from multiple sources. The Reactor pat- tern combines the simplicity and ef®ciency of single-threaded The solution to these forces event loops with the extensibility offered by object-oriented The structure and roles of classes in the solution programming. The responsibilities and collaborations among classes The positive and negative consequences of using the 2.3 Applicability pattern Use the Reactor pattern when: Implementation guidance one or more events may arrive concurrently from mul- 1 Example source code tiple sources, and blocking or continuously polling for References to related patterns events on any individual source of events is inef®cient; each individual event handler possesses the following 2.1 Intent characteristics: The Reactor pattern dispatches handlers automatically when ± it exchanges ®xed-sized or bounded-sized mes- events occur from multiple sources. This pattern simpli®es sages with its peers without requiring blocking event-driven applications by decoupling event demultiplex- I/O; ing and event handler dispatching from application services ± it processes each message it receives within a rel- performed in response to events. atively short period of time; using multi-threading to implement event demultiplex- 2.2 Motivation ing is either: Communication software must respond to events generated ± infeasible ± due to lack of multi-threading support from multiple sources. For example, network management on an OS platform; applications for monitoring and controlling space vehicles in ± undesirable ± due to poor performance on uni- the Motorola Iridium satellite constellation receive traps sent processors or due to the need for overly complex by HP OpenView agents, telemetry data sent via CORBA re- concurrency control schemes; quests, and user interface events generated by Motif. These ± redundant ± due to the use of multi-threading at events arrive on multiple I/O handles that identify resources higher levels of an application's architecture. (such as network connections) managed by an operating sys- tem. Input events from peers may arrive simultaneously on multiple handles. Therefore, single-threaded software must 2.4 Structure not block inde®nitely reading from any individual I/O han- The structure of the Reactor pattern is illustrated in the fol- dle. Blocking can signi®cantly delay the response time for lowing Booch [8] class diagram: handling events from peers associated with other handles. One way to develop this type of event-driven software is to use multi-threading. In this approach, a separate thread select (handles) Concrete foreach h in handles loop is spawned for every connected peer. Each thread blocks APPLICATION Event h->handle_event (event_type) APPLICATION on a read system call. A thread unblocks when it receives end loop Handler - an event from its associated peer. At this point, the event SPECIFIC - is processed within the thread. The thread then re-blocks INDEPENDENT awaiting subsequent input from read. Reactor There are several drawbacks to using multi-threading for dispatch() 1 handling events in communication software: register_handler(h, type) n remove_handler(h, type) threading may require complex concurrency control Event Handler schemes; 1 handle_event(type) get_handle() threading may lead to poor performance due to context Handles switching, synchronization, and data movement; n A 1Due to space limitations the sample code has been omitted from this article. See [1] for a complete example of the Reactor pattern. 2 In Booch notation dashed clouds indicate classes, an in- Event Handlers and waits for events to occur on scribed ªAºindicates an abstract class, directed edges indicate the Handles. inheritance relationships between classes, and an undirected The Reactor triggers Event Handler methods in edge with a small bullet at one end indicates a composition response to events on the Handlers it monitors. When relation between two classes. events occur, the Reactor uses the Handles acti- vated by the events as keys to locate and dispatch the 2.5 Participants appropriate Event Handler methods. This collabo- ration is structured using the method callbacks depicted The participants in the Reactor pattern include the following: in the following object interaction diagram: Handles callback : main Concrete reactor : ± Handles identify resources (such as network con- program Event_Handler Reactor : Handles nections, open ®les, and synchronization objects) Reactor()

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us