Skip to content

simplify calculations#17

Open
jaihindhreddy wants to merge 3 commits intoDevonCrawford:masterfrom
jaihindhreddy:simplify
Open

simplify calculations#17
jaihindhreddy wants to merge 3 commits intoDevonCrawford:masterfrom
jaihindhreddy:simplify

Conversation

@jaihindhreddy
Copy link

@jaihindhreddy jaihindhreddy commented Aug 27, 2018

I've made some changes which simplify the script. The details are in chronological order of commits:
Some if statements can be removed because of the two following properties of the log function:

  • log(1) == 0
  • log(a/b) + log(b/a) == 0 (given a != 0 && b != 0)
    This means you don't need to check if the old and the new values are equal, or find out which is greater than the other.

Removed unused setter methods. These can be added if and when necessary.

The ExposureChange and TemperatureChange classes aren't that different from each other, and can be eliminated by having a magnitude property in the Change class itself.
The printing of Changes can also be moved into a toString method on the Change class, and that pulls the NumToName method in there with it. This also means that private properties can be directly accessed eliminating more getter methods in the Change class.
Also, the constructor can take the magnitude of the change making the setter for magnitude redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant