Book contents
- Frontmatter
- Contents
- Preface
- 1 Introduction
- 2 Core features
- 3 Advanced features
- 4 Parser builders
- 5 XML processing
- 6 GUI programming
- 7 Concurrent programming
- 8 On paths and a bit of algebraic abstraction
- 9 Virtual files coming into existence
- 10 Compositional file matching
- 11 Searching, iterating, traversing
- 12 The expression problem
- 13 A computer algebra system
- Appendix A Multimedia processing
- Appendix B Distributing a Scala application along with Scala itself
- Appendix C Working with the compiler and the interpreter
- Appendix D Scala's grammar
- References
- Name index
- Subject index
12 - The expression problem
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- 1 Introduction
- 2 Core features
- 3 Advanced features
- 4 Parser builders
- 5 XML processing
- 6 GUI programming
- 7 Concurrent programming
- 8 On paths and a bit of algebraic abstraction
- 9 Virtual files coming into existence
- 10 Compositional file matching
- 11 Searching, iterating, traversing
- 12 The expression problem
- 13 A computer algebra system
- Appendix A Multimedia processing
- Appendix B Distributing a Scala application along with Scala itself
- Appendix C Working with the compiler and the interpreter
- Appendix D Scala's grammar
- References
- Name index
- Subject index
Summary
Introduction
The expression problem, also known as the extensibility problem, refers to the situation where we need to extend the data types of a program as well as the operations on them, with two constraints: (a) we do not want to modify existing code and (b) we want to be able to resolve types statically. Thus, the essence of the expression problem lies in the type-safe incremental modification to both the data types and their corresponding operations, without recompilation and with the support/use of static typing.
At the heart of the expression problem is the Separation of Concerns principle. Since its inception about forty years ago by Edsger Wybe Dijkstra, the Separation of Concerns principle has been elevated to one of the cornerstones of software engineering. In plain words what it states is that when tackling a problem we have to identify the different concerns that apply to the specific problem and then try to separate them. By separating the concerns, we produce untangled, clearer code, thus reducing the software complexity and increasing maintainability.
Of course, separation of concerns is only half the truth. We can identify our concerns and successfully separate them, but at some point we will need to recombine them: after all, they are parts of the original problem.
So, what exactly do we separate and then recombine in the expression problem? Data and operations are two different dimensions. Incremental modifications to these dimensions should be done independently and in an extensible way.
- Type
- Chapter
- Information
- Steps in ScalaAn Introduction to Object-Functional Programming, pp. 402 - 425Publisher: Cambridge University PressPrint publication year: 2010