Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Reflective programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Uses== Reflection helps programmers make generic software libraries to display data, process different formats of data, perform [[serialization]] and deserialization of data for communication, or do bundling and unbundling of data for containers or bursts of communication. Effective use of reflection almost always requires a plan: A design framework, encoding description, object library, a map of a database or entity relations. Reflection makes a language more suited to network-oriented code. For example, it assists languages such as [[Java (programming language)|Java]] to operate well in networks by enabling libraries for serialization, bundling and varying data formats. Languages without reflection such as [[C (programming language)|C]] are required to use auxiliary compilers for tasks like [[Abstract Syntax Notation]] to produce code for serialization and bundling. Reflection can be used for observing and modifying program execution at [[Runtime (program lifecycle phase)|runtime]]. A reflection-oriented program component can monitor the execution of an enclosure of code and can modify itself according to a desired goal of that enclosure. This is typically accomplished by dynamically assigning program code at runtime. In [[object-oriented programming]] languages such as [[Java (programming language)|Java]], reflection allows ''inspection'' of classes, interfaces, fields and methods at runtime without knowing the names of the interfaces, fields, methods at [[compile time]]. It also allows ''instantiation'' of new objects and ''invocation'' of methods. Reflection is often used as part of [[software testing]], such as for the runtime creation/instantiation of [[mock object]]s. Reflection is also a key strategy for [[metaprogramming]]. In some object-oriented programming languages such as [[C Sharp (programming language)|C#]] and [[Java (programming language)|Java]], reflection can be used to bypass [[member accessibility]] rules. For C#-properties this can be achieved by writing directly onto the (usually invisible) backing field of a non-public property. It is also possible to find non-public methods of classes and types and manually invoke them. This works for project-internal files as well as external libraries such as [[.NET Framework|.NET]]'s assemblies and Java's archives.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)