Does Object Oriented Programming Really Model The Real World? [closed]
also
"Firstly, A represents an object in the physical world, which is a strong argument for not splitting the class up." I was, unfortunately, told this when I started programming. It took me years to realize that it's a bunch of horse hockey. It's a terrible reason to group things. I can't articulate what are good reasons to group things (at least to my satisfaction), but that one is one you should discard right now. The end all, be all of "good code" is that it works right, is relatively easy to understand, and is relatively easy to change (i.e., changes don't have weird side effects). – jpmc26 8 hours ago
"Firstly, A represents an object in the physical world, which is a strong argument for not splitting the class up." I disagree with this. For example, if I had a class that represents a car, I would definitely want to split it up, because I surely want a smaller class to represent the tires. - jpmc26 11 hours ago
Until now, I considered the following a good design, because it emphasizes physical hierarchy among the objects. I would expect that to be easier to understand, than some abstractions e.g.class ViewManager
, class WheelsFascade
.
class Car
{
public:
void start() {assert(!m_fuel_tank.empty()); m_engine.start();};
private:
std::vector<Wheel> m_wheels;
Engine m_engine;
FuelTank m_fuel_tank;
}
Am I understanding correctly the above criticism that this is not a good design? If so, what are the actual problems? If not, what is being criticized?