Projects Referenced in This Catalog

Prev don't be afraid of buying books Next

Projects Referenced in This Catalog

The examples in this book either come from real-world projects or are inspired by real-world projects I've worked on. I use real-world code rather than toy code because when we refactor real-world code, our refactoring decisions are constrained by forces present in the code. This doesn't happen as much with toy code. In addition, toy code, which tends to lack these forces or contain only a portion of them, never seems to offer as rich an educational experience as real-world code.

Real-world code can take a little more effort to understand than toy code. I've tried to make it easier to understand the real-world code in this book by removing most of the extraneous details. Yet it's impossible to remove all rough edges in real-world code, and doing so could even diminish what can be learned from real-world refactorings.

The code used in the Example sections comes from diverse projects. Some of these projects are referenced only once, while others are referenced several times in different refactorings. The projects you'll find referenced in multiple refactorings are described briefly in the following subsections.

XML Builders

Many information systems I've worked on have produced XML, and nearly all of these systems have used the very basics of XML: open and closed tags, with values and attributes. When you work with the basics of XML, it often makes little sense to create XML using a sophisticated third-party library, even if it's free. You can easily write your own code to create XML exactly as you need it. I've found that my own XML code is simpler than that created by third-party tools, which must provide complex ways to create or manipulate XML.

Over the years, I've written code to create XML in numerous ways. In this book, you'll find references to an XMLBuilder, a DOMBuilder, a TagBuilder, and a TagNode. The TagBuilder is my favorite XML builder; it evolved out of my work on other XML builders.

The following refactorings contain example code involved in building XML:

  • Replace Implicit Tree with Composite (178)

  • Introduce Polymorphic Creation with Factory Method (88)

  • Encapsulate Composite with Builder (96)

  • Move Accumulation to Collecting Parameter (313)

  • Unify Interfaces with Adapter (247)

HTML Parser

The HTML Parser (http://sourceforge.net/projects/htmlparser) is an open source library that allows programs to easily parse HTML. It is the most popular HTML parser on SourceForge (http://sourceforge.net) and is used by many people throughout the world. This project was initiated by Somik Raha. Somik and others on the project made sure to write many tests as they developed the parser. When I joined the project, I found areas in the code that required design improvements. So I began refactoring, often while pair-programming with Somik. This work yielded many interesting refactorings, including numerous refactorings to patterns.

The following refactorings contain examples from the parser:

  • Move Embellishment to Decorator (144)

  • Move Creation Knowledge to Factory (68)

  • Extract Composite (214)

  • Move Accumulation to Visitor (320)

Loan Risk Calculator

I spent the first eight years of my career programming for a bank on Wall Street, creating loan calculators to assess credit, market, and global risk. At the time, I even wore suits! Some of my earliest object-oriented systems were written using Turbo Pascal and C++. While I cannot show code from those systems in this book, I can show code inspired by them. For sensitive calculations, I modified the code to use calculations you might find in any financial textbook.

The following refactorings contain examples related to my work on the loan risk calculator:

  • Chain Constructors (340)

  • Replace Constructors with Creation Methods (57)

  • Replace Conditional Logic with Strategy (129)

Amazon


Refactoring to Patterns (The Addison-Wesley Signature Series)
Refactoring to Patterns
ISBN: 0321213351
EAN: 2147483647
Year: 2003
Pages: 103

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net