What is reflection?

6

We are creating a website about computer history from the 1970s to the 1990s, and to a certain extent I found the reflective paradigm. Has this last any thing to do with reflection , what now what is it?

    
asked by anonymous 06.11.2014 / 21:25

1 answer

7

Overview

Reflection is the ability of a program to know what parts it is composed of , without requiring the programmer to enter that data manually, that is, the data about the program structure are inserted and produced automatically by the compiler in the form of metadata .

It's like a mirror, so it's called reflection: the program sees itself ... it knows its characteristics: what classes exist, what methods exist, etc.

Reflective Paradigm

Reflection also deals, by extension, with the ability of some programs to modify themselves, that is, to add more code to themselves in a dynamic way, constituting, in this way, a paradigm through which it can be programmed.

In other words, it is the paradigm that allows meta-programming, that is, besides allowing the observation of meta-data, allows the generation of new parts for the program in a dynamic way, or even the replacement of existing parts by others dynamically generated.

Therefore, the reflective paradigm is related to reflection.

Reflexive Paradigm == Meta-programming

The applications are many

  • plug-in systems: reflection allows you to search for classes that implement additional functionality within a package
  • Language Capability Expansion: IoC containers often use reflection to create objects, mocking frameworks as well, aspect-oriented programming, among many others.
  • Genetic programming: is a method of creating programs dynamically, to solve specific problems, based on the idea evolution that mimics what happens to genes
  • auto-optimization: allows a program to adapt to the form that is used at the code level
06.11.2014 / 21:43