I need to design, in my head, this is a simple system, which makes some calculations on those passed data A webform where the data is entered by the user is a web form, but a new project should use the back end code, I will start soon, which handles these calculations on the data which it exits and by itself Finds.
I originally thought that the pattern of strategies was a good fit for these back-end classes, but as I started writing them on Friday, in fact I had hit me that I had my My code is probably 95% repetition between 4 classes. Although I think my current solution will work well, if it has been decided how to change the differences of data or data, the code code repetition now makes me ejectable.
The basics are like this:
We have 4 sales programs and each of these programs has 5 assets which are different between each program but to know the formula All I need to know is equal.
Interface with a function calculation
and 4 sections (each for a program) that implement this function. All this was well and good as long as I quickly realized that calculation
and other functions implemented in my works are all 100% in the letter, the only thing in my 4 files is that There are 5 values.
The creation of my basic design plan was so much that I could key from a dropdown on the webform and could pass in that class on which my values were in it and calculate because I move it from behind So I think I have missed that mark and need to re-evaluate my structure.
I have researched some sections and even the decorator pattern but in reality there is nothing that is clicking immediately I like the idea of making it, so that other sales in the future It can be easily brought to the programs, but I do not want anyone to go into my file and copy the file and adjust the variable at the top, it seems that the slope
The easiest solution is to write only one calculator class and pass an array of these variables based on the options chosen by the user. I am trying to make it more engineer but do not feel right either with easy solution.
It seems that you are looking for a strategy pattern;)
Comments
Post a Comment