Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 49727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:28:55+00:00 2026-05-10T16:28:55+00:00

Recently I was talking to a co-worker about C++ and lamented that there was

  • 0

Recently I was talking to a co-worker about C++ and lamented that there was no way to take a string with the name of a class field and extract the field with that name; in other words, it lacks reflection. He gave me a baffled look and asked when anyone would ever need to do such a thing.

Off the top of my head I didn’t have a good answer for him, other than ‘hey, I need to do it right now’. So I sat down and came up with a list of some of the things I’ve actually done with reflection in various languages. Unfortunately, most of my examples come from my web programming in Python, and I was hoping that the people here would have more examples. Here’s the list I came up with:

  1. Given a config file with lines like
    x = ‘Hello World!’
    y = 5.0
    dynamically set the fields of some config object equal to the values in that file. (This was what I wished I could do in C++, but actually couldn’t do.)

  2. When sorting a list of objects, sort based on an arbitrary attribute given that attribute’s name from a config file or web request.

  3. When writing software that uses a network protocol, reflection lets you call methods based on string values from that protocol. For example, I wrote an IRC bot that would translate
    !some_command arg1 arg2
    into a method call actions.some_command(arg1, arg2) and print whatever that function returned back to the IRC channel.

  4. When using Python’s __getattr__ function (which is sort of like method_missing in Ruby/Smalltalk) I was working with a class with a whole lot of statistics, such as late_total. For every statistic, I wanted to be able to add _percent to get that statistic as a percentage of the total things I was counting (for example, stats.late_total_percent). Reflection made this very easy.

So can anyone here give any examples from their own programming experiences of times when reflection has been helpful? The next time a co-worker asks me why I’d ‘ever want to do something like that’ I’d like to be more prepared.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:28:56+00:00Added an answer on May 10, 2026 at 4:28 pm

    I can list following usage for reflection:

    • Late binding
    • Security (introspect code for security reasons)
    • Code analysis
    • Dynamic typing (duck typing is not possible without reflection)
    • Metaprogramming

    Some real-world usages of reflection from my personal experience:

    • Developed plugin system based on reflection
    • Used aspect-oriented programming model
    • Performed static code analysis
    • Used various Dependency Injection frameworks
    • …

    Reflection is good thing 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You'll get that error if your post-commit is failing. Try… May 11, 2026 at 3:19 pm
  • added an answer So you have a library which references WindowsForms, but doesn't… May 11, 2026 at 3:19 pm
  • added an answer Ack! Forget that, just found the answer here for anyone… May 11, 2026 at 3:19 pm

Related Questions

A co-worker recently ran into a situation where a query to look up security
I was talking to somebody a recently who mentioned it was possible to store
Recently I was talking with a friend of mine who had started a C++
I recently heard the term hook while talking to some people about a program

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.