Jump to content

Mirror (programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Fresheneesz (talk | contribs) at 05:35, 27 December 2012 (stub). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In Computer programming, a Mirror is a Reflection mechanism that is completely decoupled from the object who's structure is being introspected. This is as opposed to traditional reflection, for example in Java, where one introspects an object using methods from the object itself (e.g getClass()).

Mirrors adhere to the qualities of encapsulation, stratification, and ontological correspondence. [1]

Benefits

Decoupling the reflection mechanism from the object's themselves allows for a few benefits:

  • The object's interface isn't polluted, and so there is no danger of breaking reflection by overriding a reflective method.
  • You can have different mirror systems
  • The mirror system can be removed entirely (potentially allowing for optimizations).
  • Mirror systems can operate on remote code, since it isn't coupled with a particular machine.

Languages that use Mirrors

  • Dart, via its reflect function.

Refernces