|
| 1 | +# Refactoring / Explaining Variable |
| 2 | + |
| 3 | +Hey there! We're [thoughtbot](https://thoughtbot.com), a design and |
| 4 | +development consultancy that brings your digital product ideas to life. |
| 5 | +We also love to share what we learn. |
| 6 | + |
| 7 | +This coding exercise comes from [Upcase](https://thoughtbot.com/upcase), |
| 8 | +the online learning platform we run. It's part of the |
| 9 | +[Refactoring](https://thoughtbot.com/upcase/refactoring) course and is just one small sample of all |
| 10 | +the great material available on Upcase, so be sure to visit and check out the rest. |
| 11 | + |
| 12 | +## Exercise Intro |
| 13 | + |
| 14 | +In this exercise, you'll be extracting explaining variables within the `total` method of `Tipper`. |
| 15 | + |
| 16 | +An explaining variable is a variable whose name describes the purpose of the expression you're assigning to it. It's used to help break down longer, more complex expressions, making the final expression more manageable and easier to understand. |
| 17 | + |
| 18 | +[Read more about explaining variables](http://refactoring.com/catalog/extractVariable.html). |
| 19 | + |
| 20 | +## Instructions |
| 21 | + |
| 22 | +To start, you'll want to clone and run the setup script for the repo |
| 23 | + |
| 24 | + git clone [email protected]:thoughtbot-upcase-exercises/explaining-variable.git |
| 25 | + cd explaining-variable |
| 26 | + bin/setup |
| 27 | + |
| 28 | +Extract a few new variables whose names explain their purpose. |
| 29 | + |
| 30 | +Make sure the tests are passing by running: |
| 31 | + |
| 32 | + rake |
| 33 | + |
| 34 | +## Featured Solution |
| 35 | + |
| 36 | +Check out the [featured solution branch](https://github.com/thoughtbot-upcase-exercises/explaining-variable/compare/featured-solution#toc) to |
| 37 | +see the approach we recommend for this exercise. |
| 38 | + |
| 39 | +## Forum Discussion |
| 40 | + |
| 41 | +If you find yourself stuck, be sure to check out the associated |
| 42 | +[Upcase Forum discussion](https://forum.upcase.com/t/refactoring-explaining-variable/4636) |
| 43 | +for this exercise to see what other folks have said. |
| 44 | + |
| 45 | +## Next Steps |
| 46 | + |
| 47 | +When you've finished the exercise, head on back to the |
| 48 | +[Refactoring](https://thoughtbot.com/upcase/refactoring) course to find the next exercise, |
| 49 | +or explore any of the other great content on |
| 50 | +[Upcase](https://thoughtbot.com/upcase). |
| 51 | + |
| 52 | +## License |
| 53 | + |
| 54 | +explaining-variable is Copyright © 2015-2018 thoughtbot, inc. It is free software, |
| 55 | +and may be redistributed under the terms specified in the |
| 56 | +[LICENSE](/LICENSE.md) file. |
| 57 | + |
| 58 | +## Credits |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +This exercise is maintained and funded by |
| 63 | +[thoughtbot, inc](http://thoughtbot.com/community). |
| 64 | + |
| 65 | +The names and logos for Upcase and thoughtbot are registered trademarks of |
| 66 | +thoughtbot, inc. |
0 commit comments