Skip to Content
Refactoring: Improving the Design of Existing Code
book

Refactoring: Improving the Design of Existing Code

by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts
June 1999
Intermediate to advanced
464 pages
10h 55m
English
Addison-Wesley Professional
Content preview from Refactoring: Improving the Design of Existing Code

Chapter 9. Simplifying Conditional Expressions

Conditional logic has a way of getting tricky, so here are a number of refactorings you can use to simplify it. The core refactoring here is Decompose Conditional (238), which entails breaking a conditional into pieces. It is important because it separates the switching logic from the details of what happens.

The other refactorings in this chapter involve other important cases. Use Consolidate Conditional Expression (240) when you have several tests and all have the same effect. Use Consolidate Duplicate Conditional Fragments (243) to remove any duplication within the conditional code.

If you are working with code developed in a one exit point mentality, you often find control flags that allow the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code

Martin Fowler
Design Patterns: Elements of Reusable Object-Oriented Software

Design Patterns: Elements of Reusable Object-Oriented Software

Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Publisher Resources

ISBN: 0201485672Purchase book