|
| 1 | +refactoring101 |
| 2 | +============== |
| 3 | + |
| 4 | +.. figure:: http://i2.kym-cdn.com/photos/images/original/000/572/090/77f.jpg |
| 5 | + :alt: Draw the rest of the owl |
| 6 | + |
| 7 | + Draw the rest of the owl |
| 8 | + |
| 9 | +Inspiration |
| 10 | +----------- |
| 11 | + |
| 12 | + "`Complexity kills <http://ozzie.net/docs/dawn-of-a-new-day/>`__." ~ |
| 13 | + *Ray Ozzie* |
| 14 | + |
| 15 | + "The art of simplicity is a puzzle of complexity." ~ *Douglas |
| 16 | + Horton* |
| 17 | + |
| 18 | + "...you're not refactoring; you're just `changing |
| 19 | + shit <http://hamletdarcy.blogspot.com/2009/06/forgotten-refactorings.html>`__." |
| 20 | + ~ *Hamlet D'Arcy* |
| 21 | + |
| 22 | +Overview |
| 23 | +-------- |
| 24 | + |
| 25 | +This repo contains code samples demonstrating how to transform a |
| 26 | +complex, linear script into a modular, easier-to-maintain package. The |
| 27 | +code is written as a reference for the *Python: Beyond the Basics* class |
| 28 | +at `NICAR 2014 <http://ire.org/conferences/nicar-2014/>`__, but can also |
| 29 | +work as a stand-alone tutorial. |
| 30 | + |
| 31 | +The tutorial uses a small, `fake set of election |
| 32 | +results <https://docs.google.com/spreadsheet/pub?key=0AhhC0IWaObRqdGFkUW1kUmp2ZlZjUjdTYV9lNFJ5RHc&output=html>`__ |
| 33 | +for demonstration purposes. |
| 34 | + |
| 35 | +Project code evolves through four phases, each contained in a numbered |
| 36 | +*elex* directory. Below are descriptions of each phase, along with |
| 37 | +related questions and exercises that anticipate the next phase or set of |
| 38 | +skills. |
| 39 | + |
| 40 | +The goal is to demonstrate how to use Python functions, modules, |
| 41 | +packages and classes to organize code more effectively. We also |
| 42 | +introduce unit testing as a strategy for writing programs that you can |
| 43 | +update with confidence. The overarching theme: ***As an application or |
| 44 | +program grows in size, writing readable code with tests can help tame |
| 45 | +complexity and keep you sane.*** |
| 46 | + |
| 47 | +Wondering how to use this tutorial or why the hell we called it |
| 48 | +*refactoring101*? The |
| 49 | +`FAQ <https://github.com/PythonJournos/refactoring101/wiki/FAQ>`__ has |
| 50 | +answers to these and sundry other questions. Also, check out the |
| 51 | +`Resources <https://github.com/PythonJournos/refactoring101/wiki/Resources>`__ |
| 52 | +page for wisdom from our tribal elders. |
| 53 | + |
| 54 | + |
| 55 | +TODO |
| 56 | +---- |
| 57 | + |
| 58 | +- Convert wiki pages to rst |
| 59 | +- Add tree view of *elex4* directory; doesn't look so different from |
| 60 | + *elex3* tree view (mainly added models.py and test\_models.py), but |
| 61 | + the underlying implementation has changed dramatically (hopefully for |
| 62 | + the better) |
| 63 | +- What's Next? |
| 64 | +- Refactoring book spells out more precise steps for refactoring. |
| 65 | +- So you have a solid test suite, and want to change some code. How do |
| 66 | + you ensure all references to that code have been updated? |
| 67 | + |
| 68 | +- What didn't we cover? |
| 69 | +- *super* (for calling methods on parent classes) |
| 70 | +- Multiple inheritance and method resolution order (see the Diamond |
| 71 | + problem) |
| 72 | +- Decorators |
| 73 | +- Descriptors |
| 74 | +- Meta-programming and \_\_new\_\_ constructor |
| 75 | + |
| 76 | + |
| 77 | +.. toctree:: |
| 78 | + :maxdepth: 2 |
| 79 | + |
| 80 | + phase1 |
| 81 | + phase2 |
| 82 | + phase3 |
| 83 | + phase4 |
0 commit comments