Quantcast
Channel: refactoring Archives - XP123
Browsing latest articles
Browse All 42 View Live

Image may be NSFW.
Clik here to view.

Refactoring and Programming Language Semantics

Refactoring improves the design of code without changing its observable behavior. But what is observable behavior? We’ll look at how language semantics affect that. When you devise new refactorings,...

View Article


Loop Unrolling: While ⇒ If-While

Loop unrolling is a performance optimization where you repeat the inside of a loop to reduce the looping overhead. It’s also a way to get rid of loops, and we’ll look at an example from a test. While...

View Article


Image may be NSFW.
Clik here to view.

2021 Articles in Review

Here are the the articles and videos I made last year. Key topics: user stories, refactoring, TDD, functional languages, and design. I’ve grouped them into these areas: User...

View Article

Refactoring, a Whole-Team Guide

A one-page summary of Refactoring is available in PDF. Refactoring is…? Changing the design of existing code without changing its observable behavior (per Martin Fowler). These changes include...

View Article

Image may be NSFW.
Clik here to view.

Refactoring: Replace Method with Method Object

Sometimes, when you try to break up a long method, you run into a problem: you have to pass a bunch of local variables into the new method, some of which are both input and output. One solution is the...

View Article


Image may be NSFW.
Clik here to view.

Refactoring: Extract Local Lambda

Extracting a local lambda turns a block of code into an anonymous inline function.  Motivation A local lambda can isolate code for improvement (the Isolate-Improve-Inline pattern – see References), or...

View Article

Image may be NSFW.
Clik here to view.

Refactoring Undifferentiated Exceptions

Some exception-handling code peels apart exceptions to figure out how to handle them. This is a missed opportunity for more direct code. The Simple Case: Type-Tested Exceptions Sometimes we see...

View Article

Image may be NSFW.
Clik here to view.

Reduce Dependencies Using Lambda

When A depends on B (A → B), a change in B may force A to change as well. Dependencies are both good and bad: they let objects work together, but they make software harder to change. We can use lambda...

View Article


Refactor: Inline-Adjust-Extract

Sometimes, we feel that something we extracted isn’t as good as it could be. The Inline-Adjust-Extract refactoring pattern can help fix that. It has three steps: Inline: put the extracted code back...

View Article


TDD with a Function Pipeline

Our “geek” group tackled a problem a couple weeks ago, that one of us had heard suggested by Michael Feathers: given a sequence of numbers, tell how many non-zero runs it has. Ron Jeffries described a...

View Article
Browsing latest articles
Browse All 42 View Live