A bit of context: I'm creating a game. In this game, a player can own a house. A house can contain furniture, and custom textures can be installed on this furniture. One piece of furniture may contain a different number of textures. A piece of furniture has several slots (0 - x) for textures.
House Class:
public class House {
private List<Furniture> furniture;
public House() {
furniture = new ArrayList<Furniture>();
}
public List<Furniture> getFurniture() {
return furniture;
}
public void addFurniture(Furniture furniture) {
furniture.add(furniture);
}
}
Furniture class:
public class Furniture {
private Map<Integer, Texture> textures;
public Furniture() {
textures = new HashMap<Integer, Texture>();
}
public void setTexture(int index, Texture texture) {
textures.put(index, texture);
}
}
In the game interface for managing furniture in the house there will be something like this:
List<Furniture> furniture = house.getFurniture();
Furniture furniture = ....
furniture.setTexture(some_index, new Texture(...));
Question
Does it make sense to update my database from the setTexture method? Is interacting with a data warehouse from a data storage class a good practice?
source
share