1/11
Learn about linguistic reflection!
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
linguistic reflection
the ability of a running program to generate new program fragments and to integrate these into its own execution
reflection
provide language structures that provide run time access to other language structures
common example of reflection
classes - instances of classes are objects, which can make classes themselves
different way to call a method 1
statically - obtain a reference and make the call in the code
different way to call a method 2
dynamically - obtain a meta object for the method and construct a call using that
dynamic loading
load a class whose type we didn’t know
benefit of linguistic reflection 1
system evolution - load new objects without recompiling and extend functionality of a running system
benefit of linguistic reflection 2
build a gui that shows the code, allow interactive method calls from an interface
drawbacks for linguistic reflection 1
code becomes more verbose, you have to deal with things that are usually handled by the compiler
drawbacks for linguistic reflection 2
late error detection
drawbacks for linguistic reflection 3
performance can be reduced
tradeoffs for reflection for components
generic, can call any method on any object we have a reference to, regardless of if its available at compile time