Programming Reflection Today
Reflection is all around us in modern programming languages. Using reflection used to be hard, requiring mind-twisting designs; today's programming languages, however, have built-in reflective capabilities. In the introductory paragraphs of this chapter, I say that much of the reflection that's discussed is in the form of an idiom, used to solve an individual design problem in a specific programming language. In “Designing Architectural Reflection” — and especially in “Implementing Reflection” — I describe how to use reflection as the underlying architectural backbone of an application.
In this section, I point you to a few specific examples of reflection as it's provided in programming languages today. This section is just an introduction to language-specific reflection; it starts with a popular language that has limited reflection capabilities and progresses to the more powerful functionality provided in recent languages. The capabilities discussed here are language tools that you can use to build an architecture that adapts through Reflection.
Reflection in C++
The 1998 C++ standards included several capabilities for runtime reflection, grouped under the title Run-Time Type Information (RTTI). The typeid operator is a useful capability that accesses the type of an object. This operator is limited to returning an object's name, which allows you to compare two objects for equality. It doesn't report whether an object is a subtype of something. Another ...
Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.