ParletteSoftware / chodewars

Space exploration remake of tradewars
1 stars 0 forks source link

Redesign database functions #21

Closed matthew-parlette closed 11 years ago

matthew-parlette commented 11 years ago

With only a small number of object types in the game, the database function list is already unwieldy and not easily expandable. For example, while adding ports, you need to modify:

and add:

The problem is that add_port and get_port are basically copied from other parts of the FlatFileDatabase class definition, which generates ugly, duplicated code. This also limits the expandability, since you need to add functions to the base Database class when you want to an an object to the universe.

One part of this should be implementing load_object, which should take some sort or parameters list which will have the object type and its name

Then all of the add* and get* functions should be deprecated so the save_object and load_object are used instead. With that, there are only two functions in Database that need to be modified, and nothing added.