Abstract
The state design pattern is the standard object-oriented programming idiom for implementing the state machine logic of interactive applications. While this pattern provides a number of advantages, it does not easily support the creation of extended state machines in subclasses. We describe the extensible state design pattern, which augments the traditional state pattern with a few additional constraints that allow subclasses to easily add both new states and new events. Further, we observe that delimited continuations, a well-known construct from functional programming languages, supports state refinement in subclasses as well as the modular expression of control flow in the presence of interaction. We illustrate our pattern in the context of Java, leveraging its generics to obviate the need for dynamic typecasts and employing a small library that implements delimited continuations. We have used our pattern to simplify and modularize a widely used application written by others.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Andreae, C., Noble, J., Markstrum, S., Millstein, T.: A framework for implementing pluggable type systems. ACM SIGPLAN Notices 41(12), 57–74 (2006)
Biernacki, D., Danvy, O., Shan, C.: On the static and dynamic extents of delimited continuations. Sci. Comput. Program 60(3), 274–297 (2006)
Canning, P., Cook, W., Hill, W., Olthoff, W., Mitchell, J.C.: F-bounded polymorphism for object-oriented programming. In: Proc. of 4th Int. Conf. on Functional Programming and Computer Architecture, FPCA 1989, London, September 11-13, 1989, pp. 273–280. ACM Press, New York (1989)
Chin, B., Millstein, T.D.: Responders: Language support for interactive applications. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 255–278. Springer, Heidelberg (2006)
Dragos, I., Cunei, A., Vitek, J.: Continuations in the java virtual machine. In: Proceedings of the Second Workshop on Implementation, Compilcation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS 2007) (2007)
Ernst, E.: Family polymorphism. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)
Felleisen, M.: The theory and practice of first-class prompts. In: POPL, pp. 180–190 (1988)
Flatt, M., Yu, G., Findler, R.B., Felleisen, M.: Adding delimited and composable control to a production programming environment. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2007) (2007)
Gamma, E., Helm, R., Johnson, R.E., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Massachusetts (1995)
GBeta home page, http://www.daimi.au.dk/~eernst/gbeta
Haller, P., Odersky, M.: Event-based programming without inversion of control. In: Lightfoot, D.E., Szyperski, C.A. (eds.) JMLC 2006. LNCS, vol. 4228, pp. 4–22. Springer, Heidelberg (2006)
JDOM home page, http://www.jdom.org
Krishnamurthi, S., Hopkins, P.W., McCarthy, J., Graunke, P.T., Pettyjohn, G., Felleisen, M.: Impelementation and Use of the PLT Scheme Web Server. In: Higher-Order and Symbolic Computation (2007)
Odersky, M., Zenger, M.: Independently extensible solutions to the expression problem. In: Proc. FOOL 12 (January 2005)
Ovm home page, http://www.ovmj.org
Reynolds, J.C.: User-defined types and procedural data structures as complementary approaches to type abstraction. In: Schuman, S.A. (ed.) New Directions in Algorithmic Languages, pp. 157–168. IRIA, Rocquencourt (1975)
The Simple API for XML (SAX) home page, http://sax.sourceforge.net
The Scala language home page, http://scala.epfl.ch
Torgersen, M.: The expression problem revisited. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)
Wadler, P.: The expression problem. Email to the Java Genericity mailing list (December 1998)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2008 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Chin, B., Millstein, T. (2008). An Extensible State Machine Pattern for Interactive Applications. In: Vitek, J. (eds) ECOOP 2008 – Object-Oriented Programming. ECOOP 2008. Lecture Notes in Computer Science, vol 5142. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-70592-5_24
Download citation
DOI: https://doi.org/10.1007/978-3-540-70592-5_24
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-70591-8
Online ISBN: 978-3-540-70592-5
eBook Packages: Computer ScienceComputer Science (R0)