News for hackers. Stuff that matters.
Re:Data-oriented design or why you might shoot yourself in t... by skocznymroczny on Monday June 28, 2021 @05:20AM (#27659627)
OOP doesn't force you do do car.drive().

You can have an abstract agent class/interface with virtual "drive(Car c)" method. The method would be overriden by AIAgent, HumanAgent etc.

The car itself would have more basic behavior, such as "accelerate()", "turnLeft()", "turnRight()"

Re:Data-oriented design or why you might shoot yourself in t... by jhgb on Monday June 28, 2021 @11:54AM (#27663495)
> You can have an abstract agent class/interface with virtual "drive(Car c)" method. The method would be overriden by AIAgent, HumanAgent etc.

Is that a convoluted way of saying "use multiple dispatch", or am I reading it wrong?

Re:Data-oriented design or why you might shoot yourself in t... by bruce343434 on Monday June 28, 2021 @05:33AM (#27659699)
I think you are over engineering it. The way I imagine it:

Car {float throttle, float brake, float wheel} inherits PhysicalObject {velocity, mass, position}

Agent.accelerate(Car c){ c.throttle++; }

Agent.drive(Car c){ ... accelerate(c); ... }

Human inherits Agent

Re:Data-oriented design or why you might shoot yourself in t... by orwin on Monday June 28, 2021 @05:47AM (#27659781)
Interface is the best way to do a clean job in this case.
Re:Data-oriented design or why you might shoot yourself in t... by temporama1 on Monday June 28, 2021 @05:30AM (#27659683)
Kill me now