15: Linguistic Reflection Flashcards
what is linguistic reflection?
Linguistic reflection is the ability of a running
program to generate new program fragments and
to integrate these into its own execution
• Allow a program’s behaviour to adjust dynamically
in order to provide flexibility and high productivity.
what is marshalling?
Marshalling is converting the data present in an
object into an xml format and viewing it in an xml
format and unmarshalling is reverse of it
converting an xml file into an object.
why is linguistic reflection useful?
If we had access to an object's interface, and we could generate calls on the fly, we could do lots of interesting things o Create a method call on the fly o Call code we weren’t able to call before • Re-structure the way code interacts by allowing method calls to be decided upon and created at run-time When we load code dynamically o Find out the interface to the code o Make calls on that interface • When we want to dynamically “wrap” code o Create facades to existing classes o Code sees a different interface o ...or the same interface with different behaviour • Create in a uniform way using tools, rather than by hand
Reflection provides a way to access the meta-level
of a language
• Create dynamic skeletons for components
Benefits & Applications?
System evolution
o Load new objects/components without re-compiling
o Extend or replace functionality of a running system
o No loss of type-safety: you still can’t ever call a
method on an object that doesn’t implement it
• Code interaction
o Build a GUI that shows the code (IDEs)
o Allow interactive method calls from a user interface
(Debuggers)
o Unit Testing, Code Coverage, Dependency Injection,
Object Relational Mapping, and much more…