Hi all, I've got a question about how best to structure my code and classes.
The example I'm looking at the moment is resource management, ie, loading resources when their needed and unloading them when there not. However this is a question which could equally apply to other classes.
I've made a ResourceDatabase class which has a HashMap mapping resource name strings to instances of a Resource class which stores information about a resource's type, file location, how to load it, etc.
Currently to add a resource to the resource database you call a "addResource" function which takes a file name and other information.
This is obviously quite tedious if you have a lot of resources, hence a function that scans a folder and its subfolders for files and automatically adds any found resources to the database would be very helpful.
However, the ResourceDatabase is currently only tasked with managing a set of resources so adding this as a member function seems like its adding unrelated functionality. Also in the future I may instead want to store all resources in a single package file and add another function to scan it and add the resources.
Since the "scanFolder" function can just as easily be implemented using the ResourceDatabase's public interface is it best practice to add it as a member function or as a standalone function? If wasn't added as a member function where would you put it, just some lose function somewhere or make a class with static functions for scanning folders, package files etc?
I realize this isn't super important and either would work just as well and that responses will be opinion heavy, but I'm interested in what people think is the best way of dividing up different functionality.