What exactly is Reflective Programming
A practical example

I see me!
Reflective programming or reflection is a mechanism that enables a process perform introspective operations, examine and modify its own structure and behavior. The reflection APIs built into programming languages allow you to inspect code at runtime.
Reflection gives us the flexibility to dynamically inspect and learn about the type of an arbitrary object along with information about its underlying structure.
Some common languages that supports reflection are C#, Golang, and Java.
Reflection provides additional capabilities in compiled languages that utilize linked libraries and assemblies. Reflection APIs let you inspect the contents of loaded assemblies. In languages such as C#, you can dynamically load additional assemblies by utilizing Reflection APIs.
Reflection is often referenced in the context of object-oriented programming. You often use reflection to discover codebase entities at runtime. The language’s reflection API will let you inspect classes, methods, properties, and types from within your system. This lets you build more dynamic functionality.
Considerations
Many people would argue that implementations leveraging on Reflection would be slow, this is true when compared to static code execution of the equivalent implementation, however Reflection is used throughout many languages and framework just like the. .NET framework, and provided that it’s not abused it can be a very powerful tool in the toolkit.
Reflection may allow a user to create unexpected control flow paths through an application, potentially bypassing security measures. This may be exploited by attackers. Historical vulnerabilities in Java caused by unsafe reflection allowed code retrieved from potentially untrusted remote machines to break out of the Java sandbox security mechanism. A large scale study of 120 Java vulnerabilities in 2013 concluded that unsafe reflection is the most common vulnerability in Java, though not the most exploited. — Wikipedia
Practical Insight
Here is an example of how you can apply the knowledge of Reflective Programming to achieve dynamism:
Below is an extension method that extracts every property that is of type string and adds the property names and values to a list.
using System;
using System.Collections.Generic;
using System.Reflection;
public class Program
{
public static void Main()
{
var testObj = new {
FirstName = "Kelechi",
IsVerified = true,
Age = 21,
Motto = "F around and find out",
};
var test = testObj.GetStringProps();
test.ForEach(Console.WriteLine);
}
}
public static class MyExtensions{
public static List<string> GetStringProps(this object myObject){
List<string> myList = new List<string>();
PropertyInfo[] props = myObject.GetType().GetProperties();
foreach(var prop in props){
var propValue = prop.GetValue(myObject);
if(propValue.GetType().Equals(typeof(string))){
myList.Add($"{prop.Name}|{propValue}");
}
}
return myList;
}
}
From the code above, in the method GetStringProps, firstly, I create a list to hold the final result of the method, and then create an array variable with the PropertyInfo type accessible from the System.Reflection namespace, this gives us access to property information about an object. The GetProperties method returns an array of available public property in the object. Finally, I loop through all the returned elements in the array , then use if control statement to add properties where their values are of type string to the list. Look how I used the GetType and GetValue methods.
You can read more about Reflections in C# from
Result

Conclusion
Reflection is a programming technique that gives code introspective abilities. Effective use of reflection lets you write more dynamic systems and benefit from increased automation.