My question began as an inquiry regarding naming a new object based on a variable, but as I wrote out my problem, I realized my solution's approach may not be appropriate, so I will ask instead for general design advice. Allow me to set forth a simple example of the type of problem I'd like to solve.
Problem:
There exists a database that holds information on each planet in the solar system. The database has multiple tables.
The program intends to access this data to display it to the user in a variety of manners. The program does not intend to manipulate the data at its source, though calculations on two fields may be performed to determine certain display characteristics.
What is the optimal method for accessing the data?
My initial approach, (read: gut feeling, no research) was to take each related row of data from the database and create an object of a custom class based on the data. So you might wind up with:
Universe.Planet.Earth.mass = 1
Universe.Planet.Earth.radiusPolar = 1
Universe.Planet.Earth.radiusEquatorial = 1
Universe.Planet.Earth.aphelion = 1.106
Universe.Planet.Earth.perihelion = .983
Universe.Planet.Mars.mass = .107
Universe.Planet.Mars.radiusPolar = .531
Universe.Planet.Mars.radiusEquatorial = .533
Universe.Planet.Mars.aphelion = 1.666
Universe.Planet.Mars.perihelion = 1.381
Then use these objects to perform whatever actions the program needed to. I ran into a lot of problems trying to implement this, so that I believe my design approach is fundamentally flawed.
Any advice on how I might approach this?