What is a Reflection?

Asked

Viewed 311 times

6

We’re creating a website on the computer history of the '70s to '90s, and at a certain point I found the paradigm reflective. Has this last something to do with reflection, that by the way what is?

  • It could be what the description of the tag says or it could be something else, it’s kind of broad with no details.

  • Reflection (C# and Visual Basic) http://msdn.microsoft.com/pt-br/library/ms173183.aspx

  • 1

    Reflection is a paradigm in programming. It has more on this in this Wikipedia article. Later I can give a more elaborate answer.

1 answer

7


Overview

Reflection is the ability of a program to know of which parts it itself is composed, without requiring the programmer to enter this data manually, that is, the data on the program structure are inserted and produced automatically by the compiler in the form of meta-data.

It is like a mirror, so it is called reflection: the program sees itself... it has knowledge of its characteristics: what classes exist, what methods exist, etc..

Reflective paradigm

The reflection also deals, by extension, with the capacity that some programs have to change themselves, that is, to add more code to themselves dynamically, thus constituting, a paradigm through which one can program.

That is, it is the paradigm that allows meta-programming, that is, in addition to allowing the observation of meta-data, it allows the generation of new parts for the program dynamically, or even the replacement of existing parts by others generated dynamically.

Therefore, the reflective paradigm is related to reflection.

Reflexive paradigm == Meta-programming

The applications are many

  • plug-in systems: the reflection allows to search the classes that implement additional functionalities within a package
  • expansion of language capabilities: Ioc containers generally 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 evolutionary idea that mimics what happens to genes
  • auto-optimization: allows a program to adapt to the way it is used at the code level

Browser other questions tagged

You are not signed in. Login or sign up in order to post.