Okay, I'm working on a PROBLEM. Here it is.
The ACS dump of a ship is a component list, like this:
Code:
Components:
a Hull H 0 1 9 000000 0 200 14.0 Streamlined, 200 tons
a Driv J 1 1 9 000000 0 10 10 Jump Drive
a Driv M 1 1 9 000000 0 2 4 Maneuver Drive
a Ssen C 1 1 9 000000 1 0 0.0 Communicator
a Wwpn K 1 1 9 000000 0 1 0.3 T1 Pulse Laser
The 'a' is an item operator of sorts. And in fact it's the import format into the program: enter one of those lines into the shell and that component gets added.
The PROBLEM is that in the cases of drives and hull, I don't want to 'add' them; I want to update them if they exist already.
One way to solve that is to use a different command, say "u", that indicates "update":
Code:
Components:
u Hull H 0 1 9 000000 0 200 14.0 Streamlined, 200 tons
u Driv J 1 1 9 000000 0 10 10 Jump Drive
u Driv M 1 1 9 000000 0 2 4 Maneuver Drive
a Ssen C 1 1 9 000000 1 0 0.0 Communicator
a Wwpn K 1 1 9 000000 0 1 0.3 T1 Pulse Laser
Well yeah, but since "adding" a hull or drive is only appropriate the first time, perhaps the add-behavior of the Hull and Drive objects should be DIFFERENT than the add-behavior of any other component.
But it's not just an instance method on Hull and the parent of Drives. Rather, it's how the SYSTEM adds components to the ship. Adding a Hull. Adding a Drive. Not Polymorphism. Perhaps just method signature. Or... well perhaps just the way the Factory works (that's probably the practical solution). Or... or I need a Builder.
That's how I do it in the Desktop Shipyard: I have builder methods (alas not a Builder object) that search for things in the ship list.