I have two files :
file1 : contains the value of the variable.
file2 : contains collection of steps (subset of collection of file1 ) to follow. Step contains the set of instructions.
- > file1.txt
x1 = 34
x2 = 33
x3 = 90
...
x12 = 101
x14 = 233
..
x41 = 901
...
-> file2.txt
step 1
- x1
- x10
- x11
step 2
- x12
- x14
- x41
..
step n
..
design 1:
I create class called storeFile1
and storeFile2
basically to store what ever is in the file1 and file2.
I also have created respective parser for each of them parseFile1 and parseFile2 which
populates storeFile1
and storeFil2
. Then I place storeFile1
inside storeFile2
.
Then when user ask for step1 and its instruction I return a pair of:
storeFile2 obj;
... // filled by parsing class first
obj.get_step("step1");
1) name of step (eg step 2)
2) set of instruction (eg: {101, 233, 901})
I was wondering if doing this is bad because I break single responsibility principle.
design 2 :
What I thought would not break single responsibility principle was to create another class caled class converter
that handles the conversion.
class storefile2
returns
1) name of step (eg step 2)
2) set of instruction (eg: {x12,x14, x41})
class converter
holds class storeFile1
and class storeFile2
, does the conversion
and return
1) name of step (eg step 2)
2) set of instruction (eg: {101, 233, 901}) // after conversion
Which one of the two design do you think is good? (I also think design 2 is a little cumbersome) or is there any design better then this?