- #1
JonnyG
- 234
- 44
I am writing a simple program for my wife and would like some critique on some general design decisions I've made. The program will be able to store a recipe she enters (in a .txt file), retrieve a recipe that she had entered in the past, and allow the input and retrieval of ingredient densities (to allow her to switch from cups to grams, for example).
At first I decided on making a class called Recipe, whose data members would be string name, vector<string> ingredients, vector<double> amounts, and vector<string> units. However, I am starting to think that making a Recipe class would be unnecessary. The purpose of a class, as far as I know, is to store information that is logically related and to define behaviour (methods) for this set of information. However, because I need to store the recipes in a .txt file, it seems as if the text file is acting as my class, so to speak, because it is storing my information for me (each recipe has its own unique file name, so it's as if each file name is an instantiation of a Recipe object).
If, for example, I want to retrieve an old recipe and convert its units, I would first have to use the information in the recipe file to construct my recipe object and then convert the units. What's the point in doing that when I can just read the information in the recipe file into a primitive types (or a vector of primitive types) and manipulate the information? There seems to be no advantage to constructing a Recipe object.
Is my thinking along the right lines here or am I missing something?
At first I decided on making a class called Recipe, whose data members would be string name, vector<string> ingredients, vector<double> amounts, and vector<string> units. However, I am starting to think that making a Recipe class would be unnecessary. The purpose of a class, as far as I know, is to store information that is logically related and to define behaviour (methods) for this set of information. However, because I need to store the recipes in a .txt file, it seems as if the text file is acting as my class, so to speak, because it is storing my information for me (each recipe has its own unique file name, so it's as if each file name is an instantiation of a Recipe object).
If, for example, I want to retrieve an old recipe and convert its units, I would first have to use the information in the recipe file to construct my recipe object and then convert the units. What's the point in doing that when I can just read the information in the recipe file into a primitive types (or a vector of primitive types) and manipulate the information? There seems to be no advantage to constructing a Recipe object.
Is my thinking along the right lines here or am I missing something?