Tuesday 12 June 2007

Reflection

Reflection is the mechanism of discovering class information solely at runtime. Reflection has been introduced with the .NET framework, and its usage of metadata.

Metadata is data about data, and in .NET framework it is contained along the code, to allow, among others reflection. The Metadata consists of class names, method signatures and the like, to enable both for runtime lookup of a class (i.e reflection) but also to enable the cross language execution. When the compiler compiles code, it always create the metadata along with the compiled code, and puts it in the assembly.

Reflection means being able to get instantiate a class of a type, just by providing the name of the class at run time or invoke methods just by presenting their name.

The use of reflection is slow and should only be used when absolutely necessary (link).

Maybe more later

No comments: