CSC/ECE 517 Fall 2011/ch4 4f ss

From Expertiza_Wiki
Revision as of 14:13, 18 October 2011 by Svontel (talk | contribs) (Created page with "== Reflection == Reflection allows program entities to discover things about themselves through introspection. In other words,Reflection is the ability of a program to deter...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Reflection

Reflection allows program entities to discover things about themselves through introspection.

In other words,Reflection is the ability of a program to determine information about an object at runtime.

The information may include the following :

  • )The type of the object
  • )Inheritance structure
  • )Methods it contains.
  • )Number of parameters of the methods,types of parameters, return types.
  • ) Names and types of the attributes of the object.

Reflection is supported by many Object-oriented programminglanguages in various forms. Powerful and flexible reflection mechanisms are exhibited by Smalltalk, [1], and Python . Java also supports reflection. But reflection in java is verbose and is not as flexible and dynamic as these languages. C++ allows a program to determine the type of an object at run-time. Thus it does support reflection but in a limited form only. Eiffel also has support for a limited form of reflection which includes the ability to determine the features contained in an object.

Reflection in Ruby