| February 2003 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | |
| Oct Mar | ||||||
| Saturday, February 08, 2003 | |
I was getting really frustrated debugging a jsp yesterday. The screen revealed an ugly spew of System.out.println() debug statements had rendered my code unreadable. Realizing I was mired in reckless hacker mode, I turned off the monitor, took a breath, and decided to come up with three different ways to uncover the bug before returning to the keyboard. I grabbed my neglected copy of Refactoring for help. I had forgotten what fun this book can be.
I love the concept of code smells, "deciding when to start refactoring, and when to stop, is just as important to refactoring as knowing how to operate the mechanics of refactoring". I realized that I often resist working on this jsp-servlet project because I am not seasoned enough with J2EE to recognize the code smells. In other words, I know I am unhappy with the project's code, but I don't know why.
I also reviewed the catalog's "Composing Methods" and "Simplifying Conditional Expressions" sections. Below the name is a short summary of the situation in which you need the refactoring and a summary of what the refactoring does. Under Extract Method: "You have a code fragment that can be grouped together. Turn the fragment into a method whose name explains the purpose of the method." Under Decompose Conditional: "You have a complicated conditional (if-then-else) statement. Extract methods from the condition, then part, and else parts."
As for my jsp problem, the refactoring I used was not from the book or even Martin Fowler. It did conform to the structure of a good refactoring: it had nice, terse sections on Motivation and Mechanics, and the example was thorough (though it did meander off course at times). It was such a relief to locate this little gem, and the "Mechanics" to guide me off of the endless out.println() hamster wheel.
--------------------------------------------------------------------------------
See Also:
![]() | Aggregators (6) |
![]() | Cryptography (13) |
![]() | CSS (8) |
![]() | extremeProgramming (9) |
![]() | Java (14) |
![]() | Radio_Development (13) |
![]() | Tools (18) |