Many times there is the need to load external resources into the program, may they be graphics, audio samples or text strings.

Is there a patten for handling the loading and the handling of such resources?

For example: should I have a class that loads all the data and then call it everytime I need the data? As in:

GraphicsHandler.instance().loadAllData()
...//and then later:
draw(x,y, GraphicsHandler.instance().getData(WATER_IMAGE))
//or maybe
draw(x,y, GraphicsHandler.instance().WATER_IMAGE)


Or should I assign each resource to the class where it belongs?
As in (for example, in a game):

Graphics g = GraphicsLoader.load(CHAR01);
Character c = new Character(..., g);
...
c.draw();


Generally speaking which of these two is the more robust solution?

GraphicsHandler.instance().getData(WATER_IMAGE)
//or
GraphicsHandler.instance().WATER_IMAGE //a constant reference


You should build a house first, then paint it.

An HTML document can stand on its own, even though it may look dull. A CSS style sheet cannot; it is nothing displayable (except as code) but instructions for display.

It’s a different issue that during painting, you may wish to do changes to the house. With real houses that’s usually not feasible, but in HTML+CSS development, it’s commonplace to notice that you need extra markup in your HTML document to make styling easier. (It’s less common than it used to be, thanks to powerful CSS3 selectors.)
