Experience Using Design Patterns to Evolve Communication Software Across Diverse OS Platforms
Total Page:16
File Type:pdf, Size:1020Kb
Experience Using Design Patterns to Evolve Communication Software Across Diverse OS Platforms Douglas C. Schmidt Paul Stephenson [email protected] [email protected] Department of Computer Science Ericsson, Inc. Washington University, St. Louis, MO 63130 Cypress, CA 90630 An earlier version of this paper appeared in the proceed- at Ericsson to develop a family of object-oriented telecommu- ings of the 9th European Conference on Object-Oriented Pro- nication system software based on the ADAPTIVE Service gramming held in Aarhus, Denmark on August 7-11, 1995. eXecutive (ASX) framework [4]. The ASX framework is an integrated collection of compo- nents that collaborate to produce a reusable infrastructure for Abstract developing communication software. The framework per- forms common communication software activities (such as Design patterns help to improve communication software event demultiplexing, event handler dispatching, connection quality since they address a fundamental challenge in large- establishment, routing, con®guration of application services, scale software development: communication of architectural and concurrency control). At Ericsson, we have used the knowledge among developers. This paper makes several ASX framework to enhance the ¯exibility and reuse of net- contributions to the study and practice of design patterns. work management software, which monitors and manages It presents a case study that illustrates how design pat- telecommunication switches across multiple hardware and terns helped to reduce development effort and project risk software platforms. when evolving an object-oriented telecommunication soft- During the past year, we ported the ASX framework from ware framework across UNIX and Windows NT OS platforms. several UNIX platforms to the Windows NT platform. These Second, the paper discusses the techniques, bene®ts, and lim- OS platforms possess different mechanisms for event demul- itations of applying a design pattern-based reuse strategy to tiplexingand I/O. To meet our performance and functionality commercial telecommunication software systems. requirements, it was not possible to reuse several key compo- nents in the ASX framework directly across the OS platforms. It was possible, however, to reuse the underlying design 1 Introduction patterns embodied by the ASX framework, which reduced project risk signi®cantly and simpli®ed our re-development Developing communication software that is reusable across effort. OS platforms is hard. Constraints imposed by the under- The remainder of the paper is organized as follows: Sec- lying OS platforms may make it impractical to reuse exist- tion 2 presents an overview of the design patterns that are the ing algorithms, detailed designs, interfaces, or implemen- focus of this paper; Section 3 examines the issues that arose tations directly. This paper describes how we evolved an when we ported the components in the Reactor framework object-oriented framework from several UNIX platforms to from several UNIX platforms to the Windows NT platform; the Windows NT Win32 platform. Fundamental differences Section 4 summarizes the experience we gained, both pro and in the I/O mechanisms available on Windows NT and UNIX con, while deploying a design pattern-based system devel- platforms precluded the direct black-box reuse of framework opment methodology in a production software environment; components. We were, however, able to achieve signi®cant and Section 5 presents concluding remarks. reuse of the design patterns underlying the framework. Design patterns capturethestaticand dynamicstructures of solutions that occur repeatedly when developing applications 2 Overview of Design Patterns in a particular context [1, 2, 3]. Systematically incorporating design patterns into the software development process helps A design pattern represents a recurring solution to a design improve software quality since patterns address a fundamen- problem within a particular domain (such as business data tal challenge in large-scale software development: commu- processing, telecommunications, graphical user interfaces, nication of architectural knowledge among developers.In databases, and distributed communication software) [1]. De- this paper, we describe our experience with a design pattern- sign patterns facilitate architectural level reuse by providing based reuse strategy. We have successfully used this strategy ªblueprintsº that guide the de®nition, composition, and eval- 1 uation of key components in a software system. In general, a large amount of experience reuse is possible at the archi- tectural level. However, reusing design patterns does not Reactor Event_Handler necessarily result in direct reuse of algorithms, detailed de- register_handler(h) handle_event() signs, interfaces, or implementations. remove_handler(h) handle_close() This paper focuses on two speci®c design patterns (the dispatch() get_handle() 1 n Reactor [5] and Acceptor patterns) that are implemented by A the ASX framework. The ASX components, and the Reactor and Acceptor design patterns embodied by these components, select (handlers); foreach h in handlers loop are currently used in a number of production systems. These if (h->handle_event (h) == FAIL) systems include the Bellcore and Siemens Q.port ATM sig- h->handle_close (h); Concrete end loop Event_Handler naling software product, the system control segment for the Motorola Iridium global personal communications system [6], a family of system/network management applications for Ericsson telecommunication switches [7], and a Global Figure 1: The Structure and Participants in the Reactor Pat- Limiting System developed by Credit Suisse that manages tern credit risk and market risk. The design patterns described in the following section pro- vided a concise set of architectural blueprints that guided our callback : porting effort from UNIX to Windows NT. By using the pat- main Concrete reactor terns, we did not have to rediscover the key collaborations program Event_Handler : Reactor Reactor() between architectural components. Instead, our develop- INITIALIZE register_handler(callback) ment task focused on determining a suitable mapping of the REGISTER HANDLER components in these patterns onto the mechanisms provided MODE get_handle() EXTRACT HANDLE on the OS platforms. Finding an appropriate mapping was dispatch() non-trivial, as we describe in Section 3. Nevertheless, our INITIALIZATION START EVENT LOOP select() knowledge of the design patterns signi®cantly reduced re- FOREACH EVENT DO development effort and minimized the level of risk in our handle_event() EVENT OCCURS projects. MODE EVENT REMOVE HANDLER handle_close() HANDLING 2.1 The Reactor Pattern The Reactor is an object behavioral pattern that decouples Figure 2: Object Interaction Diagram for the Reactor Pattern event demultiplexing and event handler dispatching from the services performed in response to events. This separation of concerns factors out the demultiplexing and dispatching anisms perform event demultiplexing and dispatching of mechanisms (which may be independent of an application application-speci®c event handlers in response to events. The and thus reusable) from the event handler processing policies Event Handler speci®es an abstract interface used by (which are speci®c to an application). The Reactor pattern the Reactor to dispatch callback methods de®ned by ob- appears in many single-threaded event-driven frameworks jects that register to handle input, output, signal, and timeout (such as the Motif, Interviews [8], System V STREAMS [9], events of interest. The Concrete Event Handler se- the ASX OO communication framework [4], and implemen- lectively implements callback method(s) to process events in tations of DCE [10] and CORBA [11]). an application-speci®c manner. The Reactor pattern solves a key problem for single- Figure 2 illustrates the collaborations between participants threaded communication software: how to ef®ciently demul- in the Reactor pattern. These collaborations are divided into tiplex multipletypes of events from multiplesources of events two modes: within a single thread of control. This strategy provides coarse-grained concurrency control that serializes application 1. Initialization mode ±whereConcrete Event event handling within a process at the event demultiplexing Handler objects are registered with the Reactor; level. One consequence of using the Reactor pattern is that 2. Event handling mode ± where methods on the objects the need for more complicated threading, synchronization, or are called back to handle particular types of events. locking within an application may be eliminated. Figure 1 illustrates the structure and participants in the An alternative way to implement event demultiplexingand Reactor pattern. The Reactor de®nes an interface for dispatching is to use multi-tasking. In this approach, an ap- registering, removing, and dispatching Event Handler plicationspawns a separate thread or process that monitors an objects. An implementation of this interface provides a event source. Every thread or process blocks until it receives set of application-independent mechanisms. These mech- an event noti®cation. At this point, the appropriate event 2 2. How to make the connection establishment code 1 Reactor portable across platforms that may contain different net- 1 work programming interfaces (such as sockets but not n TLI, or vice versa); PEER_STREAM 1 Svc SVC_HANDLER Handler Acceptor PEER_ACCEPTOR 3. How to ensure that a passive-mode