phetsims / reactants-products-and-leftovers

"Reactants, Products and Leftovers" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 4 forks source link

Potential to refactor in GameGuess.js #13

Closed aaronsamuel137 closed 9 years ago

aaronsamuel137 commented 9 years ago

I'm guessing you're aware of this, but it seems like the three methods createGuessReactants, createGuessProducts, and createGuessLeftovers could be pretty easily refactored into single method createGuessSubstances. In fact, createGuessProducts and createGuessLeftovers look identical semantically with just different variable names.

Any reason why you are not refactoring these?

See code review #5.

pixelzoom commented 9 years ago

This implementation went through a significant evolution, so thanks for pointing out the similarity between private functions. createGuessProducts and createGuessLeftovers are indeed identical. But createGuessReactants is actually different; it sets quantities to zero in a different situation (when we're guessing the 'Before' quantities). Rather than combine into one function, it was simpler to just inline these functions, see my commit above. If this looks good, feel free to close.

aaronsamuel137 commented 9 years ago

Looks good to me. Closing