I know according to open closed principle, something like class,interface,code.... should be unchanged when add new functions or contents, but is file also in this case?
I was designing a game, the game have some monster information, and the game (in client side) may download or replace some file if there are new monsters to add or update.
I was worrying what should be the format of monster information: 1 file with all monster information or each monster has individual file?
1.Store all monster information into a single file (e.g.:monsterlist.json),each time add new monster it will replace the file e.g.:
{
"monsterList":[
{
"id":1,
"hp":100,
"attack":230,
},
{
"id":2
"hp":500
"attack":980
}
]
}
2.Each monster has a individual file,each time add a new monster will also add a new monster json:
monster1.json
{
"id":1,
"hp":100,
"attack":230,
}
monster2.json
{
"id":2,
"hp":500,
"attack":980,
}
At start I think case 1 is most convenient, because when I add or update any monsters I only need to replace monsterlist.json, but for case 2, I need to know which json is new (may need extra row to store the update status in server database).
But suddenly I remember open closed principle, adding something new should not modify the current content, it seems not reasonable to replace a file when a new monster is added.
Note: I am not asking which format is better (which is opinion based), the example above is just the background information to illustrate why I would have this question. The thing I want to ask is just : is “file” also participate in open closed principle?