Hello everyone. Recently I started working on a project, which can be summarized as follows:
- there is a cartesian grid;
- on this grid, there are warehouses;
- these warehouses contain products;
- the products are delivered to customers, who are also on the grid, via drones;
- more stuff that isn’t pertinent here.
and was told, that I can use this resource as the blueprint for a solution:
https://eloquentjavascript.net/07_robot.html
Now, as usual, I have a go at projects without looking at a resource, especially a resource that is supposed to be a comprehensive one, and this time it was no different. I struggled my way through node.js concepts (I had no JS knowledge beforehand), did my usual OOP approach I learned in Python - classes and objects for everyone and everything! Then I got to the core algorithm for the deliveries, and decided to have a gander at the JS book. And lo and behold, there is this section, which took me by surprise (and also took the wind out of my sails completely):
"To be able to simulate this process, we must define a virtual world that can describe it. This model tells us where the robot is and where the parcels are. When the robot has decided to move somewhere, we need to update the model to reflect the new situation.
If you’re thinking in terms of object-oriented programming, your first impulse might be to start defining objects for the various elements in the world: a class for the robot, one for a parcel, maybe one for places. These could then hold properties that describe their current state, such as the pile of parcels at a location, which we could change when updating the world.
This is wrong.
At least, it usually is. The fact that something sounds like an object does not automatically mean that it should be an object in your program. Reflexively writing classes for every concept in your application tends to leave you with a collection of interconnected objects that each have their own internal, changing state. Such programs are often hard to understand and thus easy to break."
Somehow, while I was designing and working at the implementation, I had this feeling that I would have a really hard time making the different parts of it work together.
So I’m here now wondering, how do I learn this state-oriented programming? What am I missing here?