DELAPARRA
Index
Color
NL
Category: Programming paradigms

Reflection

Explained by Updated

What is Reflection?

Reflection: Inspecting a program's own structure at runtime — listing a class's methods, or checking a value's type dynamically. Reflection is a program's ability to inspect its own structure while running: list a class's methods and properties, read their types and attributes, or check what a function expects as arguments. Frameworks rely on it heavily. Laravel's service container uses reflection to see which dependencies a constructor needs and injects them automatically. Routing, validation and serialisation libraries read attributes and types the same way.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Reflection

What should you keep in mind with Reflection?

In your own application code, reflection is rarely the right tool. It is slower than direct calls, bypasses the normal visibility rules and makes code harder for editors and static analysis to follow. It is excellent for building frameworks, test tools and generic utilities, and best kept out of everyday business logic.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with R

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.