I have a doubt that extends across a few examples and programming languages: c++ and python (and then extend it to SQL). I will try to be as concise as possible, but I am aware it is stemming from, in a big proportion, a lack of general knowledge, so, if at the end of the examples all you have left to recommend is a full book, I will be glad to receive the recommendation. Trying to summarize the question, is regarding the cappacity but also how advisable it is to make an interplay between strings and code to make it more versatile and extensible to more use cases. This is simmilar I think to the concept or reflective programming. To start with the examples: I had to program a few sorting algorithms on c++, and there were a few example cases. I wanted to make a code that allowed the user to select based on which attribute the objects should be compared to make the sorting. One of the example cases was a set of sales registers. I represented the attributes as a class Register that implemented the "<" comparison. I couldn't do it overwriting the < operator because I was giving it more arugments: (Also, because I used Templates, this method had to be implemented in the header file (.h)) class Register{ public: //static int s_id; int m_product_id{}; int m_amount_sold{}; float m_unit_price{}; Date m_date; // Special class. Not important here Registro(int product_id, int m_amount_sold, float m_unit_price, const Date& m_date); //getters void setId(); friend std:stream& operator<<(std:stream& os, Register& register); //Comparison with respect to member received as argument. template<typename memberT> bool menor(Register* ptr_reg, memberT member){ return this->*member < ptr_reg->*member; } }; (Then, one of the structures was a linked list, so I had to implement the Node class with a member variable m_data of type Register). This allowed me to reference the attribute itself, so, for example, in the main.cpp file, There would be a line that invoked the merge sort based on amount sold. listm.mergeSort(&Register::m_amount_sold); Regarding this example my question is basically that this feels way to complex for this kind of solution, but it would be worse to have a code filled with switch case statements, and even if I did that, I would still need to make something similar to access the attribute specified by user. In the case of Python, I discovered recently namedTuple, in which, citing the code snipet from GeeksforGeeks you can do the following: from collections import namedtuple Point = namedtuple('Point', ['x', 'y']) p = Point(x=1, y=2) print(p.x, p.y) Also, following the Wikipedia page on refelctive programming, you can reference an attribute with getattr as shown: # Without reflection obj = Foo() obj.hello() # With reflection obj = globals()["Foo"]() getattr(obj, "hello")() In this example I created an object in which the attribute names where specified directly from strings. This is the heart of my question. When I did the c++ code I was trying to solve heuristically a problem but this python example make things much more versatile. Another example could be from variable name definitions in sympy or in Matlab, when you define the variables: x = optimvar('x'); y = optimvar('y');. The last example I have in my mind is DB managers as any SQL motor, in which you specify certain strings and then they are recognized as variable names. Other example and the reason I say my question is related to reflective programming is this example from _______ in which they present this Julia code: julia> struct Point x::Int y end # Inspection with reflection julia> fieldnames(Point) x, :y) julia> fieldtypes(Point) (Int64, Any) julia> p = Point(3,4) # Access with reflection julia> getfield(p, :x) 3 With this methods you would be able to access and reference directly (in the case of Julia with a symbol) the attribute name you are referring to. But how could one implement such a method in Julia, for example? In general, I am trying to understand how to generally achieve this common behaviour. Continue reading...