Pro-Tip

TDD Pro-Tip: Design Until Nervous Optimism

TDD Pro-Tip: Before I write the first test in a new context, I usually design until I get to a state of "Nervous Optimism". A couple of days ago, I was party to some drinking geekery with my colleagues at a hookah bar restaurant dance club. It was the end of a long day, and we were unwinding and being pretty silly. My three partners in crime mobbed on "Evil Hangman", a fun little game. And I sat off to […]

TDD Pro-Tip: Design Until Nervous Optimism See Full Post

TDD Pro-Tip: Stay Aware Of Testing Data

TDD Pro-Tip: I stay very aware of my testing context’s data, and specifically of what data is opaque and what data is transparent. Those terms, transparent and opaque, need a little explanation. Sometimes the code I’m testing doesn’t vary based on the entirety of its input. A trivial example, the function that validates the date of an order DOES NOT CARE what any other field in that order is or does. It only cares about the date field. I would

TDD Pro-Tip: Stay Aware Of Testing Data See Full Post

Refactoring Pro-Tip: Scanning Isn’t Just Fast Reading

Refactoring Pro-Tip: When I’m scanning, I’m not just reading fast, I’m feature-detecting, something the unconscious part of me is very good at doing, especially when the code helps. Part of the made, the making, and the maker as a guiding theme for me is the idea of "leaning in" to the strengths of my maker body and "leaning out" from its weaknesses. A trivial case: one reason TDD works so well for me is that the microtests give me a

Refactoring Pro-Tip: Scanning Isn’t Just Fast Reading See Full Post

Refactoring Pro-Tip: I Optimize Scannability, Then Readability, Then Writability

Refactoring Pro-Tip: I optimize my code for scannability, readability, and writeability in that order. I won’t argue my case in detail, there’s a video if you’d rather watch me make it instead of reading it, and I’ll just sketch the case briefly here in the muse. http://geepawhill.org/optimizing-a-program-and-programming/ When I’m coding, I notice that I spend significantly more time scanning the code than I do reading it, and significantly more time reading the code than I do writing it. So when

Refactoring Pro-Tip: I Optimize Scannability, Then Readability, Then Writability See Full Post

Refactoring Pro-Tip: Making Local Variables Maximally Local

Refactoring Pro-Tip: When I tackle a long method, the first thing I do is make my local variables maximally local. Consider this psuedo-code. It’s basic stuff, I’m betting virtually any geek can read it, but if not, lemme know. longMethod( int y ) { int x; x = 0; // … // IRRELEVANCY #0: 87 lines that neither read nor write x // … if( y == 17 ) { x = 1; } // … // IRRELEVANCY #1: 87

Refactoring Pro-Tip: Making Local Variables Maximally Local See Full Post

Refactoring Pro-Tip: Naming, Isolation, and Noise-Filtering

Refactoring Pro-Tip: I use naming, isolation, and noise-filtering as strategies to keep the coder’s intention at my fingertips. (I’m actually jonesing to write some geeky material in this series, but I’ve got one more of these pesky abstract philosophy things before I can get there.) First, a silly line from a silly movie, Airplane, which makes for a good Friday night comedy if you want that. (Paraphrased from memory.) "There’s a problem in the cockpit." "The cockpit? What is it?"

Refactoring Pro-Tip: Naming, Isolation, and Noise-Filtering See Full Post

Refactoring Pro-Tip: Refactor to Enable Change

Refactoring Pro-Tip: The triggering events for refactoring vary, but the reason we refactor at all is the same each time, regardless of occasion: we refactor to enable change. The most obvious and direct occasion for a refactoring is this: I want to add new functionality and preserve old functionality, and it will be easier to add if I first schmoosh the old functionality around a little to make a little hole where the new stuff will fit. When I do

Refactoring Pro-Tip: Refactor to Enable Change See Full Post

Refactoring Pro-Tip: Terrible Code Doesn’t Mean Terrible People

Refactoring Pro-Tip: Terrible code is not a good excuse to be mean, because terrible code is not well-correlated with having been written by terrible people. Look, y’all, it’s me, here. I love a good rant as much as the next Old Testament prophet, surely you know this. But . . . but . . . When I work with a new team, a key element of what I do is figure out how to integrate my line of advice, which

Refactoring Pro-Tip: Terrible Code Doesn’t Mean Terrible People See Full Post

Refactoring Pro-Tip: Easiest Nearest Owwie First

Refactoring Pro-Tip: "Easiest Nearest Owwie First". When facing especially weak code, it’s easy to feel daunted; there just seems so much wrong with it. To get my mojo on, I find the simplest infelicity to fix, I fix it. Then I do it again. Everyone encounters code from time to time that she does not understand. This is true for the noob and equally so for the olb. It is a fact of being a geek. Early in one’s refactoring

Refactoring Pro-Tip: Easiest Nearest Owwie First See Full Post

Pro-Tip (Refactoring): Prioritize Reading Code

Pro-Tip (Refactoring): Prioritize reading the code over learning about the application domain. Not so long ago, I worked with a team that was hacking a humongous (>3mloc) perl codebase with their main focus being performance. I set out to show them that the crazy crap I was showing them about TDD and refactoring would be useful. The critical call was to a method that had to update patient status using a variety of pretty complex logic. We’d brought just that

Pro-Tip (Refactoring): Prioritize Reading Code See Full Post

Scroll to Top