Does Object Oriented Programming Really Model The Real World? [closed]
anche
"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
Fino ad ora, ho considerato il seguente un buon design, perché enfatizza la gerarchia fisica tra gli oggetti. Mi aspetto che sia più facile da capire, rispetto ad alcune astrazioni, ad esempio 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;
}
Sto capendo correttamente la critica di cui sopra che questo non è un buon design? Se sì, quali sono i problemi attuali? In caso contrario, quale viene criticato?