Michael C. Feathers's Blog, page 4
December 9, 2015
Variable Capture Considered Harmful
According to wikipedia, after Dijkstra’s letter Go To Statement Considered Harmful there were at least 65 papers published with titles like ‘X Considered Harmful’, most of them generating heat but little light. I’m using the convention ironically because, well, this is just a nit. It shouldn't be controversial all. :-)
Variable capture is the use of an externally defined variable inside of a closure or block. It's something you'll see in most code that uses closures, and often it&...
September 21, 2015
The Universality of Postel's Law
Design is deep topic. One could say it’s the deepest. It’s about making decisions that affect choices in the world. When you design a chair, what you’ve really done is make a set of choices about how people using it will sit and what their experience will be like. People sitting on chairs have choices too. They can defy your expectations by turning the chair on its side and sitting on it that way. That makes them designers as well. Design is wonderful interactive game.
Below this game, there...
July 1, 2015
Moving Past the Scaling Myth
I’m going to the Agile 2015 conference this year. It’ll be the first time I’ve been to that conference in about five years. Agile has been around for over 15 years now and at a certain point you feel like you’ve seen the important developments. In truth, I felt that way years ago but I kept going to agile conferences primarily to catch up with friends and colleagues and offer advice to people new to agility.
If I have to put my finger on it, though, I think that the main reason that I stopped...
The Myth of Scaling
I’m going to the Agile 2015 conference this year. It’ll be the first time I’ve been to that conference in about five years. Agile has been around for over 15 years now and at a certain point you feel like you’ve seen the important developments. In truth, I felt that way about 10 years ago but I kept going to agile conferences primarily to catch up with friends and colleagues and offer advice to people new to Agile.
If I have to put my finger on it, though, the main reason that I stopped going...
April 27, 2015
Collection Pipelines - The Revenge Of C
What do Ruby’s Enumerable module, .NET LINQ, and the new Java Stream package have in common? They are all there to facilitate functional programming. Here’s an example, pulled from Java 8’s docs because its support is the most recent.
int sum = widgets.stream() .filter(b -> b.getColor() == RED) .mapToInt(b -> b.getWeight()) .sum();Chances are, you’ve been seeing a lot of this sort of code recently. I’m sure you’ll see more of it.
To me, its a very attractive style. It nearly eliminate...
February 16, 2015
A Monadic Approach to Error Handling in Collection Pipelines
If you read my last blog you know that I’ve been pushing the idea of chained computation rather far. It’s been fun to just try to use it for all of my utility programming to see where it breaks down. When you build a program as a single expression in a single sequential flow, one of the things that you have to deal with is making sure that you have all of the information you need at each stage of the pipeline. If you don’t organize your design well, you’ll be passing along extra arguments tha...
January 8, 2015
Moving Quickly with Compositional Chains
When you find a more powerful tool, it’s hard to avoid using it. We like to think of this as the ‘if all you have is a hammer, everything looks like a nail’ syndrome, but the fact of the matter is - I have plenty of tools. It’s just that some are more powerful and it's hard not to use them.
Last night, I was playing noise music at an art space with a friend, and I met a couple of other guys who were doing interesting work. One of them had done a bit of programming and was excited about the...
December 21, 2014
Detecting Refactoring Diligence
We’re really at a point in the industry where all developers should be aware of the importance of continuous refactoring. It’s easy to look at deteriorating code bases and get the sense that if only we’d done large refactorings along the way things would be better. But, code goes bad slowly and it happens through a predictable process. We add code to existing methods, making them longer, and we add methods to existing classes making them bigger. In the former case, the effect is particularly...
November 25, 2014
Detecting Shoved Code
I’m constantly amazed at how biological code seems. It grows and it sprawls. It becomes easier to patch than change deeply. I have this theory that any system the where the cost of changing old structure is high has a strong biological feel. Code, in the worst cases, is like a decaying city. It's easy to add a new sign or a clean up a single storefront but hard to replace the sewer or the streets.
The fact of the matter is that the industry has to start taking refactoring much more serious...
August 25, 2014
Using Repository Analysis to Find Single Responsibility Violations
I’ve been thinking about cohesion, coupling, and the Single Responsibility Principle quite a bit recently. The other day I realized that cohesion is harder to explain or understand than coupling. I figured I’d put that thought out into the world via twitter (not realizing that Glenn Vanderburg had said essentially the same thing about four years ago).
In my response to my tweet, Richard Dalton (@ricardadalton) replied “Figuring out if two people are married is easy. Figuring out if they should...