From Play-In Scenarios to Code: an Achievable Dream
Total Page:16
File Type:pdf, Size:1020Kb
COVER FEATURE From Play-In Scenarios to Code: An Achievable Dream A development scheme for complex reactive systems leads from a user- friendly requirements capture method, called play-in scenarios, to full behavioral descriptions of system parts, and from there to final implementation. 1 David Harel n a 1992 Computer article, I tried to present an system model, most notably its structure and behav- The Weizmann optimistic view of the future of development ior. The linking of structure and behavior is crucial Institute of methods for complex systems. Research since and by no means a straightforward issue. In SA/SD, Science then only supports this optimism, as I will for example, each system function or activity is asso- I attempt to show. ciated with a state machine or a statechart2 that This article presents a general, rather sweeping describes its behavior. In OOAD, as evident in the development scheme, combining ideas that have been Unified Modeling Language (UML)3 and its exe- known for a long time with more recent ones. The cutable basis, the XUML,4 each class is associated scheme makes it possible to go from a high-level user- with a statechart, which describes the behavior of friendly requirements capture method—which I call every instance object. The “Structured Analysis and play-in scenarios—via a rich language for describing Structured Design” and “Object-Oriented Analysis message sequencing to a full model of the system, and and Design” sidebars give some background on these from there to final implementation. modeling approaches. A cyclic process of verifying the system against An indispensable part of any serious modeling requirements and synthesizing system parts from the approach is a rigorous semantical basis for the model requirements is central to the proposal. The article puts constructed—notably, for the behavioral parts of the special emphasis on the languages, methods, and com- model and their connection with the structure. It is puterized tools that allow smooth but rigorous tran- these semantics that lead to the possibility of execut- sitions between the various stages of the scheme. In ing models and running actual code generated from contrast to database systems, this article focuses on them. (The code need not result in software; it could systems that have a dominant reactive, event-driven be in a hardware description language, leading to real facet. For these systems, modeling and analyzing hardware.) Figure 1 shows system modeling with full behavior is the most crucial and problematic issue. code generation. Obviously, if we have the ability to generate full code, MODELING THE SYSTEM we would eventually want that code to serve as the Over the years, the main approaches to high-level basis for the final implementation. Some current tools, system modeling have been structured-analysis/struc- like Statemate and Rhapsody from I-Logix Inc. or Rose tured-design (SA/SD) and object-oriented analysis and RealTime from Rational Corp., can in fact produce design (OOAD). The two modeling approaches are quality code, good enough for the implementation of about a decade apart in initial conception and evolu- many kinds of reactive systems. And there is no doubt tion. Over the years, both approaches have yielded that the techniques for this kind of “supercompilation” visual formalisms for capturing the various parts of a from high-level visual formalisms will improve in time. Providing higher levels of abstraction with automated downward transformations has always been the way to An early version of this article appeared in Proc. Fundamental Approaches to Software Eng. (FASE), Lecture Notes in Computer go, as long as the engineers who do the actual work are Science, vol. 1783, Springer-Verlag, Berlin, Mar. 2000, pp. 22-34. happy with the abstractions. 0018-9162/01/$10.00 © 2001 IEEE January 2001 53 Figure 1. System modeling with full Code code generation. The generation system model Code consists of structure and behavior System model depicted using visual SPECIFYING REQUIREMENTS formalisms in When developing a complex system, it is very executable UML Structure important to be able to test and debug the model before investing extensively in implementation— (XUML) or structured 1 analysis/structured hence, the desire for executable models. design (SA/SD). A Requirements are the basis for testing and debugging rigorous semantical by executing the model. By their very nature, require- Behavior basis makes it possi- ments constitute the constraints, desires, and hopes we ble to automatically entertain concerning the system under development. generate full runable We want to make sure, both during development and code from the model. when we feel development is over, that the system does, or will do, what we intend or hope for it to do. (XUML or SA/SD) Figure 2 shows system modeling with full code gen- eration and soft links to requirements. Requirements can be formal (rigorously and precisely defined) or Structured Analysis and Structured Design SA/SD, which started in the late 1970s, chassis, wheels, and so on—and an River, N.J., 1979. is based on raising classical procedural engine, then you merely stick the engine 3. P. Ward and S. Mellor, Structured Devel- programming concepts to the modeling under the hood and you are done.) The opment for Real-Time Systems: Volumes level and using diagrams, or visual for- three teams struggled with this issue, and 1-3, Yourdon Press, New York, 1985. malisms, as the languages for modeling their decisions on how to link structure 4. D. Hatley and I. Pirbhai, Strategies for system structure. Structural models are with behavior ended up being very similar. Real-Time System Specification, Dorset based on functional decomposition and Careful behavioral modeling and its close House, New York, 1987. information flow and are depicted by hier- linking with system structure are espe- 5. D. Harel et al., “STATEMATE: A Working archical dataflow diagrams. cially crucial for reactive systems,7,8 of Environment for the Development of Com- Many methodologists were instrumental which real-time systems are a special case. plex Reactive Systems,” IEEE Trans. Soft. in setting the ground for the SA/SD paradigm Statemate, released in 1987, was the first Eng., vol. 16, no. 4, 1990, pp. 403-414; al- by devising the functional decomposition and commercial tool to enable model execution so in Proc. 10th Int’l Conf. Soft. Eng., IEEE dataflow diagram framework, including and code generation from high-level mod- Press, Piscataway, N.J., 1988, pp. 396-406. Tom DeMarco1 and Larry Constantine and els5 (http://www.ilogix.com). Modeling 6. D. Harel, “Statecharts: A Visual Formal- Ed Yourdon.2 David Parnas’s work over the Reactive Systems with Statecharts: The ism for Complex Systems,” Science of years was very influential, too. STATEMATE Approach9 gives an updated Computer Programming, vol. 8, 1987, pp. In the mid-1980s, three methodology and detailed summary of the SA/SD lan- 231-274; also tech. report CS84-05, The teams—Ward and Mellor,3 Hatley and guages, their relationships, and the way Weizmann Institute of Science, Rehovot, Pirbhai,4 and the Statemate team5— they are embedded in Statemate. Israel, 1984. enriched this basic SA/SD model by using Of course, modelers don’t need to 7. D. Harel and A. Pnueli, “On the Develop- state diagrams or the richer language of adopt state machines or statecharts to ment of Reactive Systems,” in Logics and statecharts6 to add behavior to these describe behavior. Many other possible Models of Concurrent Systems, K.R. Apt, efforts. A state diagram or statechart is languages can be linked with the SA/SD ed., NATO ASI Series, vol. F-13, Springer- associated with each function or activity, structural diagrams. They include visual Verlag, New York, 1985, pp. 477-498. describing its behavior. Many nontrivial formalisms such as Petri nets or SDL dia- 8. A. Pnueli, “Applications of Temporal issues had to be worked out to properly grams and more algebraic methods like Logic to the Specification and Verification connect structure with behavior, enabling Communicating Sequential Processes or of Reactive Systems: A Survey of Current modelers to construct a comprehensive Calculus of Communicating Systems. Trends,” Current Trends in Concurrency, and semantically rigorous model of the J. de Bakker et al., eds., Lecture Notes in system. It is not enough to simply decide References Computer Science, vol. 224, Springer-Ver- on a behavioral language and then asso- 1. T. DeMarco, Structured Analysis and Sys- lag, Berlin, 1986, pp. 510-584. ciate each function or activity with a tem Specification, Yourdon Press, New 9. D. Harel and M. Politi, Modeling Reac- behavioral description. (This would be York, 1978. tive Systems with Statecharts: The like saying that when you build a car, all 2. L.L. Constantine and E. Yourdon, Struc- STATEMATE Approach, McGraw-Hill, you need are the structural things—body, tured Design, Prentice Hall, Upper Saddle New York, 1998. 54 Computer Figure 2. System Code modeling with “soft” generation links to requirements. Code Developers check the System model model against requirements by exe- cuting the model (testing and debug- Structure ging). Developers use Testing and debugging; model execution various methodolo- gies to go from the Use cases requirements to the model. In general, Behavior however, these processes are not comprehensive, not Requirements Development guaranteed to methodologies succeed, and not fully automated. (Message sequence charts) (XUML or SA/SD) Object-Oriented Analysis and Design The late 1980s saw the first proposals now part of the Rational RealTime tool (see Trans. Database Systems, vol. 1, no. 1, for object-oriented analysis and design http://www.rational.com). 1976, pp. 9-36. (OOAD). As in SA/SD, the basic idea in Another tool is Rhapsody (http://www. 2. G.