I am in the process of developing an datastore for my iOS app.
I have written an datastore which is an wrapper around NSMutableArray (say method "addObjectToDataStore" used to add data to the datastore).
I use the datastore throughout the various classes in my app to collect data (key/value pair) which I save onto it using static method exposed by the datastore class. Archiving of data on app exit and unarchiving of datacollector data is done my main appdelegate class.
This data from the datastore I read periodically and use for reporting purpose.
I'll have to trim/remove outdated/unused/stale data periodically (say once a day), so that the datastore size does not bloat.
My questing is with respect to the trimming of datastore data.
Whose responsibility is it to trim the data? I plan to expose an method "trim" in datastore class which might accept the trimming criteria(say max file size) and accordingly trim the data.
But not sure if that violates the "Single responsibility principle" for datastore class.
And who should have the responsibility of calling this "trim" method?
Should I call the "trim" method form the main appdelegate class or should I call the "trim" method from within "addObjectToDataStore" method of the datastore class such that when the criteria is satisfied, it would trim the data?
I have written an datastore which is an wrapper around NSMutableArray (say method "addObjectToDataStore" used to add data to the datastore).
I use the datastore throughout the various classes in my app to collect data (key/value pair) which I save onto it using static method exposed by the datastore class. Archiving of data on app exit and unarchiving of datacollector data is done my main appdelegate class.
This data from the datastore I read periodically and use for reporting purpose.
I'll have to trim/remove outdated/unused/stale data periodically (say once a day), so that the datastore size does not bloat.
My questing is with respect to the trimming of datastore data.
Whose responsibility is it to trim the data? I plan to expose an method "trim" in datastore class which might accept the trimming criteria(say max file size) and accordingly trim the data.
But not sure if that violates the "Single responsibility principle" for datastore class.
And who should have the responsibility of calling this "trim" method?
Should I call the "trim" method form the main appdelegate class or should I call the "trim" method from within "addObjectToDataStore" method of the datastore class such that when the criteria is satisfied, it would trim the data?