Stories about Software


The Narrative of Mediocrity

I was defeated. Interested in getting off to a good start and impressing, I had overachieved in the course by working hard and studying diligently to make a good impression. And yet, when the first essay was returned to the class, mine had a big, fat B staring back at me, smug with the kind of curves that are refreshingly absent in a nice, crisp A. I didn’t understand how this had happened, and the fact that none of the other students had received As either was cold comfort. I’d sought to impress, but the teacher had put me in my place.

I got an A in that class. I actually don’t remember which class it was any longer because it happened in a number of them. It happened in high school, college, and graduate school. I started off a B student on subjectively-graded assignments and ‘improved’ steadily for the duration of the course until I wound up with an A. Many of my peers followed the same trajectory. It was a nice story of growth and learning. It was the perfect narrative…for the teacher.

What could be better than a fresh-faced crop of students, talented but raw, eager to learn, being humbled and improving under the teacher’s tutelage? It’s the secondary education equivalent of a Norman Rockwell painting. It gives the students humility, confidence, and a work ethic, and it makes the teacher look and feel great. Everyone wins, so really, what’s the harm in the fiction? So what if it’s a bit of a fabrication? Who cares?

Well, I did. I was a relentless perfectionist as a student and this sort of evaluation drove me nuts. I sought out explanations for early B’s in classes where this happened and found no satisfaction in the explanations. I raged against the system and eventually cynically undercut it, going out of my way to perform the same caliber of work in the before and after pictures, doggedly determined to prove conspiracy. My hypothesis was confirmed by my experiments–my grades improved even as my work did not–and my triumphant proof of conspiracy was met with collective yawns and eye-rolls by anyone who actually paused long enough to listen to me.

I learned a lesson as a child and young adult about the way the academic world worked. Upon graduation from college, I was primed to learn that the business world worked that way too.

The Career Train

There are a lot of weird symmetries, quirks, and even paradoxes in the field of macroeconomics. It’s truly a strange beast. Consider, for instance, the concept of inflation, wherein everyone gets more money and money becomes worth less, but not necessarily in completely equal proportions. We’re used to thinking of money in a zero-sum kind of sense–if I give you ten dollars, then I am ten dollars poorer and you are ten dollars richer. But through the intricacies of lending and meta-transactions surrounding money, we can conceive of a scheme where we start with ten dollars and each wind up with six dollars some time later. And so it goes in life–as time goes by, we all have more money (at least in lending-based, market economics). If things get out of whack and everyone doesn’t have more money as time goes by, you have stagnation (or deflation). If things get out of whack the other way, you wind up with runaway inflation and market instability. They system works (or at least works best) when everyone gets a little more at a measured, predictable, and homogeneous pace.

The same thing seems to happen throughout our careers. We all start in the business world as complete initiates, worth only our entry level paychecks, and we all trudge along throughout our careers, gradually acquiring better salaries, titles, accessories, and office locations. Like a nice but not-too-steep interest rate, people have an expectation of dependable, steady, slight gain throughout their career. Two promotions in your twenties is pretty reasonable. Managing a team by your mid thirties. A nice office and a VP or director title in your later forties, and perhaps a C-level executive position of some kind when you’re in your fifties to sixties. On average, anyway. Some real go-getters might show their prodigious talents by moving that timeline up by five years or so, while some laggards might move it back by the same amount, topping out at some impressive but non-executive title.

Okay, so I know what you’re thinking. You want to shout “Mark Zuckerberg!” at me. Or something along those lines–some example of a disruptive entrepreneur that proves there is a different, less deterministic path. Sure, there is. People who opt out of the standard corporate narrative do so at large risk and large possible reward. Doing so means that you might be Zuckerberg or that Instagram guy, but it means that you’re a lot more likely to be working in your garage on something that goes nowhere while your friends are putting in their time in their twenties, getting to the best cubicles, offices, and corner offices a few years before you do. By not getting on the train when all your friends do, you’re going to arrive later and behind them–unless you luck out and are teleported there by the magic teleportation fairy of success.

So forget the Zuckerbergs and the people who opt out in the negative sense and never get back in. Here in corporate land, the rest of us are on a train, and there’s not a lot of variance in arrival times on trains. If you get right to the front of the train, you may get there a few minutes early, but that’s all the wiggle-room you get. The upside to this mode of transportation is that trains are comfortable, dependable, and predictable. A lot of people prefer to travel this way, and the broad sharing of cost and resources make it worth doing. It’s a sustainable, measured pace.

Everyone Meets Expectations

They don’t stop two trains on the track so that people who are fast and serious about going fast can sprint to the next train. It may be good for a few, but it would enrage the many and throw the system out of whack. That applies to trains, and it applies to your performance reviews. The train runs on time, and the only question is whether you’re in the front (exceeds expectations) or the back (meets some expectations). If you’re perennially in front, you’ll get that C-Level corner office at fifty, but perennially in back, and you’ll just be the sales manager at fifty.

Seem cynical? If so, ask yourself this: why are there no office prodigies? In school, there were those kids who skipped a grade or who took Algebra with the eighth graders while their fellow seventh graders were in Pre-Algebra. There were people who took AP classes, aced their SATs, and who achieved great, improbable things. What happens to those outliers in the corporate world, if they don’t drop out and go the Zuckerberg route? Why is there no one talented enough to rocket through the corporate ranks the way there was in school? Doesn’t that seem odd? Doesn’t it seem like, by sheer odds, there should be someone who matches Zuckerberg as a twenty-something wunderkind CEO by coming up through the corporate world rather than budging back in from entrepreneur-land? Maybe just one, like, ever?

I would think so. I would think that corporate prodigies would exist, if I didn’t know better–if I didn’t know that the mechanism of corporate advancement was a train, a system designed to quite efficiently funnel everyone toward the middle. You might exceed expectations or fail to meet them at any given performance review, but on a long enough timeline, you meet expectations because everyone meets expectations. It’s the most efficient way to create a universal and comfortable narrative for everyone. That narrative is that all of everyone’s work and achievement through life has built toward something. That the corner office is the product of forty years of loyalty, dedication, and cleverness. After forty years of meeting expectations, you, too, can finally arrive.

This isn’t some kind of crazy conspiracy theory. This is transparently enforced via HR matrices. All across the nation and even the world, there are corporate policies in place saying that level six employees can’t receive two promotions before level seven employees receive one. It wouldn’t be fair to pay Suzy more than Steve since Steve has three more years of industry experience. Organizations, via a never-ending collection of superficially unrelated policies, rules, regulations, and laws, take a marathon and put it on a single-file people-mover.


Wither the Performance Review

So if I had a parallel experience with a manufactured narrative in school and the corporate world, how to explain grade-skippers and AP-takers? Simple. In school, the narrative occurs for the benefit of the teacher on the micro (single quarter or semester) level. In the work world, it occurs for everyone’s benefit for the rest of your working life.

So why do organizations bother with the awkward performance review construct? Well, in part because it’s necessary to make justifications about issues like pay, position, and promotions. If people receive titular, “career-advancing” promotions every three to four years, a review is necessary in the first year to tell them that they need to “get better at business” or something. Then in the second year, they can hear that they’re making “good strides at business,” followed in the third year by a hearty congratulations for “being great at business,” and, “really earning that promotion to worker IV.” Like a scout earning a merit-badge, this manufactured narrative will be valued by the ‘earner’ because it supplies purpose to the past three years, even if the person being reviewed didn’t “get better at business” (whatever that means). But the other purpose is providing the narrative for the reviewers. If the reviewers’ reports started out “bad at business” and ‘improved’ under his tutelage, his own review narrative goes a lot better, and so on, recursively, up the chain. What a wonderful world where everyone is helping everyone get better at a very measured pace, steadily, over the course of everyone’s career.

But just as I railed against this concept in school, so do I now. I’ve never received sub-standard reviews. In general annual review parlance, mine have typically been “exceeds expectations but…” where “but” is some reason that I’m ‘not quite ready’ for a promotion or more responsibility just yet. Inevitably, this magically fixes itself.

So what if we did as Michael O. Church suggests and simply eliminate the performance reviews along these lines? Poof. Gone. I don’t know about you, but I might just find a “we’re not promoting you because that’s our policy” refreshingly honest as compared to a manufactured and non-actionably vague piece of ‘constructive’ criticism. (This is not to be confused with a piece of feedback like “your code should be more modular,” or, “you should deliver features more quickly,” both of which are specific, actionable, and perfectly reasonable critiques. But also don’t require some kind of silly annual ceremony where I find out if I’m voted onto Promotion Island or if I’ll have to play again next year.) I certainly don’t have an MBA, and I’m not an expert in organizational structuring and management, but it just seems to me as though we can do better than a stifling policy of funneling everyone toward the middle and manufacturing nonexistent deficiencies so that we can respond by manufacturing empty victories. I can only speak for myself, but you can keep the guaranteed trappings of ascending the corporate ladder if you just let me write my own story in which my reach exceeds my grasp.


Guerilla Guide to Developer Interviews

Over the course of my career I’ve done quite a number of technical interviews, and a pretty decent cross-section of them have ended in job offers or at least invitations to move on to the next step. That said, I am no expert and I am certainly no career coach, but I have developed some habits that seem pretty valuable for me in terms of approaching the interview process. Another important caveat here is that these are not tips to snag yourself an offer, but tips to ensure that you wind up at a company that’s as good a fit as possible. Sometimes that means declining an offer or even not getting one because you realize as you’re interviewing that it won’t be a good fit. On any of these, your mileage may vary.

So in no particular order, here are some things that you might find helpful if you’re throwing yourself out there on the market.

Avoid the Firehose

Programming jobs are becoming more and more plentiful, and, in response to that demand, and contrary to all conventional logic about markets, the supply of programmers is falling. If you work as a programmer, the several emails a week you get from recruiters stand in not-so-mute testimony to that fact. If you decide that it’s time to start looking and throw your resume up on Dice, Monster, and CareerBuilder, your voicemail will fill up, your home answering machine will stop working, and your email provider will probably throttle you or start sending everything to SPAM. You will be absolutely buried in attempts to contact you. Some of them will be for intern software tester; some of them will be for inside sales rep; some of them will be for super business opportunities with Amway; some of them won’t even be in your native language.


Once you do filter out the ones (dozens) that are complete non-starters, you’ll be left with the companies that have those sites on some kind of RSS or other digital speed dial, meaning that they do a lot of hiring. Now, there are some decent reasons that companies may do a lot of hiring, but there are a lot of not-so-decent reasons, such as high turnover, reckless growth, a breadth-over-depth approach to initial selection, etc. To put it in more relatable terms, imagine if you posted a profile on some dating site and within seconds of you posting it, someone was really excited to meet you. It may be Providence, but it also may be a bit worrisome.

The long and short of my advice here is that you shouldn’t post your resume immediately to sites like these. Flex your networking muscle a bit, apply to some appealing local companies that you’d like to work at, contact a handful of recruiters that you trust, and see what percolates. You can always hit the big boards later if no fish are biting or you start blowing through your savings, but if you’re in a position to be selective, I’d favor depth over breadth, so to speak.

Don’t Be Fake

When it comes time to the do the actual interview, don’t adopt some kind of persona that you think the interviewers want to see. Be yourself. You’re looking to see whether this is going to be a fit or not, and while it makes sense to put your best foot forward, don’t put someone else’s best foot forward. If you’re a quiet, introverted thinker, don’t do your best brogrammer imitation because there’s a ping pong table in the other room and the interviewers are all 20-something males. You’re probably going to fail to fit in anyway, and even if you don’t, the cultural gulf is going to continue to exist once you start.

And above all, remember that “I don’t know” is the correct answer for questions to which you don’t know the answer. Don’t lie or try to fake it. The most likely outcome is that you look absurd and tank the interview when you could have saved yourself a bit of dignity with a simple, “I’m not familiar with that.” But even if this ruse somehow works, what’s the long-play here? Do you celebrate the snow-job you just pulled on the interviewer, even knowing that he must be an idiot (or an Expert Beginner) to have fallen for your shtick? Working for an organization that asks idiots to conduct interviews probably won’t be fun. Or perhaps the interviewer is perfectly competent and you just lucked out with a wild guess. In that case, do you want to hire on at a job where they think you’re able to handle work that you can’t? Think that’ll go well and you’ll make a good impression?

If you don’t know the answers to questions that they consider important, there’s a pretty decent chance you’d be setting yourself up for an unhappy stay even if you got the job. Be honest, be forthright, and answer to the best of your ability. If you feel confident enough to do so, you can always pivot slightly and, for instance, turn a question about the innards of a relational database to an answer about the importance of having a good DBA to help you while you’re doing your development work or something. But whatever you do, don’t fake it, guess, and pray.

Have the Right Attitude

One of the things I find personally unfortunate about the interview process is how it uniquely transports you back to waiting to hear whether or not you got into the college of your dreams. Were your SAT scores high enough? Did you play a varsity sport or join enough clubs? Did you have enough people edit your essays? Oh-gosh-oh-gee I hope they like me. Or, really, I hope I’m good enough.

Let me end the suspense for you. You are. The interview process isn’t about whether you’re good enough, no matter how many multiple choice questions you’re told to fill out or how much trivia an interviewer sends your way in rapid fire bursts of “would this compile!?” The interview process is ultimately about whether you and the company would be a good mutual fit. It isn’t just a process to help them determine if you’d be able to handle the work that they do. It’s also a chance for you to evaluate whether or not you’d like doing the work that they give you. Both parts are equally important.

So don’t look at it as you trying to prove yourself somehow. It’s more like going to a social event in an attempt to make friends than it is like hoping you’re ‘good’ enough for your favorite college. Do you want to hang out with the people you’re talking to for the next several years of your life? Do you have similar ideas to them as to what good software development entails? Do you think you’d enjoy the work? Do you like, respect, and understand the technologies they use? This attitude will give you more confidence (which will make you interview better), but it also sets the stage for the next point here.

Don’t Waste Your Questions

In nearly every interview that I’ve ever been a part of, there’s the time for the interviewer to assess your suitability as a candidate via asking you questions. Then there’s the “what questions do you have for me” section. Some people will say, “nothing — I’m good.” Those people, as any career site or recruiter will tell you, probably won’t get an offer. Others will take what I believe is fairly standard advice and use this time as an opportunity to showcase their good-question-asking ability or general sharpness. Maybe you ask impressive sounding things like, “what’s your five year plan,” or, “I have a passionate commitment to quality as I’m sure you do, so how do you express that?” (the “sharp question” and “question brag,” respectively).

I think it’s best to avoid either of those. You can really only ask a handful of questions before things start getting awkward or the interviewer has to go, so you need to make them count. And you’ll make them count most by asking things that you really want to know the answer to. Are you an ardent believer in TDD or agile methodologies? Ask about that! Don’t avoid it because you want it to be true and you want them to make an offer and you don’t want to offend them. Better to know now that you have fundamental disagreements with them than six months into the job when you’re miserable.

As an added bonus, your interviewer is likely to be a pretty successful, intelligent person. She’s probably got a fairly decent BS detector and would rather you ask questions to which you genuinely want to know the answers.

Forge your Questions in the Fires of Experience

So you’re going to ask real questions, but which questions to ask… My previous suggestion of “ones you want the answer to” is important, but it’s not very specific. The TDD/agile question previously mentioned is an example of one good kind of question to ask: a question which provokes an answer that interests you and gives you information about whether you’d like the job. But I’d take it further than this.

Make yourself a list of things you liked and didn’t like at previous jobs, and then start writing down questions that will help you ferret out whether the things you liked or didn’t will be true at the company where you’re interviewing. Did you like way your last company provided you with detailed code reviews because it helped you learn? Ask what kinds of policies and programs they have in place to keep developers current and sharp. Did you not like the mess of interconnected dependencies bogging down the architecture of the code at your last stop? Ask them what they think of Singleton as a design pattern. (I kid, but only kind of.)

You can use this line of thinking to get answers to tough-to-ask questions as well. For instance, you’re not going to saunter into an interview and say, “So, how long before I can push my hours to second shift and stroll in at 2 PM?” But knowing things about a company like dress code, availability of flex hours, work-from-home policy, etc. is pretty valuable. Strategize about a way to ask about these things without asking–even during casual conversation. If you say something like “rush hour on route 123 out there seems pretty bad, how do people usually avoid it,” the next thing you hear will probably be about their flex hours policy, if the company has one.

Negative Bad, Zero-Sum Fine

Another piece of iconic advice that you hear is “don’t talk badly about your former/current employer.” I think that’s great advice to be on the safe side. I mean, if I’m interviewing you, I don’t want to hear how all of your former bosses have been idiots who don’t appreciate your special genius, nor do I want to hear juicy gossip about the people at your office. Staying upbeat makes a good impression.

That said, there is a more nuanced route you can travel if you so choose, that I think makes you a pretty strong candidate. If I’m interviewing you, I also know that your former positions aren’t all smiles and sunshine or you wouldn’t be sitting in front of me. When talking about past experience, you can go negative, but first go positive to cancel it out.

My current employer has some really great training programs, and I’ve enjoyed working with every project manager that I’ve been paired with. That’s contributed to me enjoying the culture–and feeling a sense of camaraderie, too. Of course, there were some things I might have done differently in our main code base, from an architectural perspective. I’d have liked to see a more testable approach and an IoC container, perhaps, but I realize that some things take time to change, especially in a legacy code base.

Now you’ve communicated that you recognize that the architectural approach to your code base was sub-optimal, but that you maintain a positive attitude in spite of that. Instead of the interviewer hearing, “man, those guys over there are procedural-code-writing cretins,” he hears, “some things were less than ideal, and I’d like them to improve, but I grow where I’m planted.”

Gather your Thoughts

After you’re done, stop and write down what you thought. I mean it. Walk out of the building, and in your car or on a nearby bench, plop down and write your impressions while they’re fresh in your mind. What did you like, what worries you, what questions should you follow up with, what specifics can you cite? Things will be fuzzy later, and this information is solid gold now.

Your brain is going to play weird tricks on you as time goes by and you’re considering an offer or the next round of interviews. Something that struck you as a red flag might be smoothed over in your mind as you grow increasingly tired of your job hunt. I know they said that they’re as waterfall as Niagra and proud, but I think the tone of voice and non-verbal cues might have indicated a willingness to go agile. You’ll fool yourself. You’ll talk yourself into things. That is, unless you write them down and bring them up as concerns the next time you talk with the company or a representative thereof.

Maintain Perspective

Interviewing is an inherently reductionist activity, both for you and for the company. Imagine if marriage worked like job interviews. The proposition would be put to you and your potential mates this way:

Alright, so you have have about two or three cracks at this whole marriage thing before you’re too old for it, so take your time and make a good decision and all that, but do it really fast. You’re going to meet for lunch, a little Q&A, and then you’ll have just enough time to send a thank-you note before you hear thumbs up or thumbs down from your date. If it’s thumbs up, you have a few days to decide if the prenuptial agreement looks good, if you have similar opinions on when to have children and how many, yadda-yadda, and hurry up, and, “do you take this person to be your lawfully wedded, blah, blah, you may now kiss, etc., whatever, done.

Think a few important details might get missed in that exchange? Think you might be left after an inexplicable rejection, stammering, “b-b-but I know how to cook and I really have a lot to offer… why… I just don’t get it.” It’s pretty likely. There are going to be a lot of bad decisions and the divorce rate will be pretty high.

Back to the interview process, just remember to keep your chin up. You might have interviewed for a job that had already been filled except for the detail of technically having to interview a second person. Maybe the CEO’s son got the job instead of you. Maybe you wore a gray suit and the man interviewing you hates the color gray with a burning passion. Maybe you had a lapse when talking about your WPF skills and said WCF, and someone thinks that makes you a moron. The list goes on, and it often makes no sense. It makes no sense in the way that you’ll look at a company’s website and see a weirdly blinking graphic and think it looks unprofessional and decide not to apply there. You make snap judgments, and so do they. It’s the name of the game. Don’t take it personally.


How to Keep Method Size Under Control

Do you ever open a source code file and see a method that starts at the top of your screen and kind of oozes its way to the bottom with no end in sight? When you find yourself in that situation, imagine that you’re reading a ticker tape and try to guess at where the method actually ends. Is it a foot below the monitor? Three feet? Does it plummet through the floor and into the basement, perhaps down past the water table and into the earth’s mantle?


Visualized like this, I think everyone might agree that there’s some point at which the drop is too far, though there’s likely some disagreement on where exactly this is. Personally, I used to subscribe to the “fits on a screen” heuristic and would only start looking to pull out methods if it got beyond that. But in more recent years, I think even smaller. How small? I dunno–five or six lines, max. Small enough that you’ll only ever see one try-catch or control flow statement in there. Yeah, seriously, that small. If you’re thinking it sounds kind of crazy, I get that, but give it a try for a while. I can almost guarantee that you’ll lose your patience for looking at methods that cause you to think, “wait, where was loopCounter declared again–before the second or third while loop?”

If you accept the premise that this is a good way to do things or that it might at least be worth a try, the first thing you’ll probably wonder is how to go about doing this from a practical standpoint. I’ve definitely encountered people and even whole groups who considered method sizes like this to be impractical. The first thing you have to do is let go of the notion that classes are in some kind of limited supply and you have to be careful not to use too many. Same with modules, if your project gets big enough. The reason I say this is that having small methods means that you’re going to have a lot of them. This in turn means that they’re going to need to be spread to multiple classes, and those classes will occupy more namespaces and modules. But that’s okay. If you encounter a large application that’s well designed and factored, it’s that way because the application is actually a series of small, focused components working together. Monolithic doesn’t scale well.

Getting Down to Business

If you’ve prepared yourself for the reality of needing more classes organized into more namespaces and modules, you’ve really overcome the biggest obstacle to being a small-method coder. Now it’s just a question of mechanics and practice. And this is actually important–it’s not sufficient to just say, “I’m going to write a lot of methods by stopping at the fifth line, no matter what.” I guarantee you that this is going to create a lot of weird cross-coupling, unnecessary state, and ugly things like out parameters. Nobody wants that. So it’s time to look to the art of creating abstractions.

As a brief digression, I’ve recently picked up a copy of Uncle Bob Martin’s Clean Code: A Handbook of Agile Software Craftsmanship and been tearing my way through it pretty quickly. I’d already seen most of the Clean Coder video series, which covers some similar ground, but the book is both a good review and a source of new and different information. To be blunt, if you’re ever going to invest thirty or forty bucks in getting better at your craft, this is the thing to buy. It’s opinionated, sometimes controversial, incredibly specific, and absolute mandatory reading. It will change your outlook on writing code and make you better at what you do, even if you don’t agree with every single point in it (though I don’t find much with which to take issue, personally).

The reason I mention this book and series is that there is an entire section in the book about functions/methods, and two of its fundamental points are that (1) functions should do one thing and one thing only, and (2) that functions should have one level of abstraction. To keep those methods under control, this is a great place to start. I’d like to dive a little deeper, however, because “do one thing” and “one level of abstraction per function” are general instructions. It may seem a bit like hand-waving without examples and more concrete heuristics.

Extract Finer-Grained Details

What Uncle Bob is saying about mixed abstractions can be demonstrated in this code snippet:

Do you see what the issue is? We have a method here that describes (via sub-methods that are not pictured) how to open a door. The first two calls talk in terms of actions between you and the door, but the next three calls suddenly dive into the specifics of how to pull the door open in terms of actions taken by your muscles, joints, tendons, etc. These are two different layers of abstractions: one about a person interacting with his or her surroundings and the other detailing the mechanics of body movement. To make it consistent, we could get more detailed in the first two actions in terms of extending arms and tightening fingers. But we’re trying to keep methods small and focused, so what we really want is to do this:

Create Coarser Grained Categories

What about a different problem? Let’s say that you have a method that’s long, but it isn’t because you are mixing abstraction levels:

These items are all at the same level of abstraction, but there are an awful lot of them. In the previous example, we were able to tighten up the method by making the abstraction levels consistent, but here we’re going to actually need to add a layer of abstraction. This winds up looking a little better:

In essence, we’ve created categories and put the actions from the long method into them. What we’ve really done here is create (or add to) a tree-like structure of methods. The public method is the root, and it had thirteen children. We gave it instead four children, and each of those children has between two and five children of its own. To tighten up methods, it’s perfectly viable to add “nodes” to the “tree” of your call stack. While “do one thing” is still a little elusive, this seems to be carrying us in that direction. There’s no individual method that you look at and think, “boy, that’s a lot of stuff going on.” Certainly its a matter of some art and taste, but this is probably a good way to think of it–organize stuff into hierarchical method categories until you look at each method and think, “I could probably memorize what that does if I needed to.”

Recognize that Control Flow Uses Up an Abstraction

So far we’ve been conceptually figuring out how to organize families of methods into well-balanced tree structures, and that’s taken us through some pretty mundane code. This code has involved none of the usual stuff that sends apps careening off the rails into bug land, such as conditionals, loops, assignment, etc. Let’s correct that. Looking at the code above, think of how you’d modify this to allow for the preparation of an arbitrary number of quesadillas. Would it be this?

Well, that makes sense, right? Just like the last version, this is something you could read conversationally while in the kitchen just as easily as you do in the code. Prep your ingredients, then prep your equipment, then for some integer index equal to zero and less than the number of quesadillas you want to cook, increment the integer by one. Each time you do that, cook the quesadilla. Oh, wait. I think we just went careening into the nerdiest kitchen narrative ever. If Gordon Ramsey were in charge, he’d have strangled you with your apron for that. Hmm… how ’bout this?

Well, I’d say that the CookQuesadillas method looks a lot better, but do we like “PerformActualCooking?” The whole situation is an improvement, but I’m not a huge fan, personally. I’m still mixing control flow with a series of domain concepts. PerformActualCooking is still both a story about for-loops and about cooking. Let’s try something else:

We’ve added a node to the tree that some might say is one too many, but I disagree. What I like is the fact that we have two methods that contain nothing but abstractions about the domain knowledge of cooking and we have a bridging method that brings in the detailed realities of the programming language. We’re isolating things like looping, counting, conditionals, etc. from the actual problem solving and story telling that we want to do here. So when you have a method that does a few things and you think about adding some kind of control flow to it, remember that you’re introducing a detail to the method that is at a lower level of abstraction and should probably have its own node in the tree.

Adrift in a Sea of Tiny Methods

If you’re looking at this cooking example, it probably strikes you that there are no fewer than eighteen methods in this class, not counting any additional sub-methods or elided properties (which are really just methods in C# anyway). That’s a lot for a class, and you may think that I’m encouraging you to write classes with dozens of methods. That isn’t the case. So far what we’ve done is started to create trees of many small methods with a public method and then a ton of private methods, which is a code smell called “Iceberg Class.” What’s the cure for iceberg classes? Extracting classes from them. Maybe you turn the first two methods that prepare ingredients and equipment into a “Preparer” class with two public methods, “PrepareIngredients” and “PrepareEquipment.” Or maybe you extract a quesadilla cooking class.

It’s really going to vary based on your situation, but the point is that you take this opportunity pick nodes in your growing tree of methods and sub-methods and convert them into roots by turning them into classes. And if doing this leads you to having what seems to be too many classes in your namespace? Create more namespaces. Too many of those in a module? Create more modules. Too many modules/projects in a solution? More solutions.

Here’s the thing: the complexity exists no matter how many or few methods/classes/namespaces/modules/solutions you have. Slamming them all into monolithic constructs together doesn’t eliminate or even hide that complexity, though many seem to take the ostrich approach and pretend that it does. Your code isn’t somehow ‘simpler’ because you have one solution with one project that has ten classes, each with 300 methods of 7,000 lines. Sure, things look simple when you fire up the IDE, but they sure won’t be simple when you try to debug. In fact, they’ll be much more complicated because your functionality will be hopelessly interwoven with weird temporal couplings, ad-hoc references, and hidden dependencies.

If you create large trees of functionality, you have the luxury of making the structure of the tree the representative of the application’s complexity, with each node an island of simplicity. It is in these node-methods that the business logic takes place and that getting things right is most important. And by managing your abstractions, you keep these nodes easy to reason about. If you structure the tree correctly and follow good OOP design and practice, you’ll find that even the structure of the tree is not especially complicated since each node provides a good representative abstraction for its sub-tree.

Having small, readable, self-documenting methods is no pipe dream. Really, with a bit of practice, it’s not even very hard. It just requires you to see code a little bit differently. See it as a series of hierarchical stories and abstractions rather than as a bunch of loops, counters, pointers, and control flow statements, and the people that maintain what you write, including yourself, will thank you for it.


Language Basics from Unit Tests

Let’s say that in a green field code base someone puts together a type that conceptually is a collection of non-integer values. For the sake of discussion, let’s call it a graph. A graph object might store a series of two-element tuples or perhaps a series of some value type like “point.” The graph might then perform operations on this data, such as IncreaseX() or IncreaseY() or Invert() or Divide()–operations that iterate through the points and do things to them. The actual mechanics of this don’t matter a whole lot. It’s the concept that’s important.

Now let’s say that in the graph the internal representation of the points is a floating point data type such as, well, float. I’m going to save the nuance of floating point arithmetic for a future practical math post, but suffice it say that floats can exhibit some weird-seeming behavior when it comes to comparisons, truncation/rounding, certain kinds of casting and type representations, etc.

[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Mind_Equals_Blown()
float x = 0.2f;
float y = 0.1f;
float z = x + y;

Assert.IsTrue(z == x + y); //What the - why does this fail?!?

And let's also say that the person responsible for authoring this graph class hasn't read a practical math post about floating point arithmetic and is completely oblivious to these potential pitfalls.

And, finally, let's say that this graph class becomes a mainstay of the business logic in a particular application. It's modified, extended, and relied heavily upon without a whole lot of attention paid to its internal workings. At least until stuff mysteriously doesn't work. But when that happens, the culprit isn't immediately obvious, so strange work-arounds and cargo-cult, oddball solutions spring up when symptoms occur. Extension methods are written, and sometimes entirely different modules are added to the code base because the existing one is "tricky" or "not to be trusted."

At the application level, this causes maintenance issues, a lot of heated and fruitless arguments, and voodoo approaches to code. From a user interface perspective, this causes quirky behavior. Occasionally a linear graph is completely displaced out of the graph and rendered on some menu somewhere, or the screen goes blank for a few seconds and then the display is restored. Defects and defect reports are created and developers dispatched to track down the issue, but after a few days of fruitless efforts, some project manager quietly sets the defect's priority from "critical" to "cosmetic" and the software is shipped. It's embarrassing, but whatcha gonna do. Ya know, computers have a mind of their own sometimes!


Catching it Early

What if, instead of doing things the old-fashioned but all-too-common way, the authors of this code had been writing unit tests and/or practicing TDD? Well, there's a very good chance that the issue stemming from the graph library is caught immediately as its API methods are being fleshed out from a functionality perspective. There's a good chance that someone is writing a test and gets to the point that we were at in the code sample above, where they are utterly dumbfounded as to why 1+1 does not equal 2 in float land.

And then, good things happen. The developer in question takes to google or stack overflow, or perhaps he talks to other, more experienced developers on his team. He then gets an explanation, learns something about the language, and leaves the code in a correct state. Contrast this with the non-tested approach of "code it up, build a bad house on the bad foundation, and then ship the result because it's too late."

And what if the TDD/unit tests don't expose this issue? Well, what they'll do in either case is decouple the code base. So when the issue eventually does crop up via weird GUI behavior, it will be much easier to isolate. When it's isolated, it will be much easier for the unit-test-savvy developers to write a test that exposes the defect to learn the lesson and fix the issue. It's still a win.

The point about unit tests helping catch errors and leading to a more decoupled design is hardly controversial. But the benefits go beyond that. Unit tests provide a fast feedback loop for all points in the code base, which lends itself very well to poking and prodding things and experimenting. And that, in turn, leads to better understanding of not only the code, but also the language. If you can execute and get feedback on code extremely quickly, you're much more likely to ask questions like, "I wonder what happens if I do x..." and then to do it and see. And that sort of experimentation, much like immersion in natural language, leads much more quickly to fluency.


What Drives Waterfall Projects?

To start off the week, I have a satirical post about projects developed using the waterfall ‘methodology.’ (To understand the quotes, please see my post on why I don’t think waterfall is actually a methodology at all). I figured that since groups that use agile approaches and industry best practices have a whole set of xDD acronyms, such as TDD, BDD, and DDD, waterfall deserved a few of its own. So keep in mind that while this post is intended to be funny, I think there is a bit of relevant commentary to it.

Steinbeck-Driven Development (SDD)

For those of you who’ve never had the pleasure to read John Steinbeck’s “Of Mice and Men,” any SDD practitioner will tell you that it’s a heartwarming tale of two friends who overcome all odds during the Great Depression, making it cross-country to California to start a rabbit petting zoo. And it’s that outlook on life that they bring to the team when it comes to setting deadlines, tracking milestones, and general planning.


Relentlessly optimistic, the SDD project manager reacts to a missed milestone by reporting to his superiors that everything is a-OK because the team will just make it up by the time they hit the next one. When the next milestone is missed by an even wider margin, same logic applies. Like a shopping addict or degenerate gambler blithely saying, “you gotta spend money to make money,” this project manager will continue to assume on-time delivery right up until the final deadline passes with no end in site. When that happens, it’s no big deal–they just need a week to tie up a few loose ends. When that week is up, it’ll just be one more week to tie up a few loose ends. When that week expires, they face reality. No, just kidding. It’ll just be one more week to tie up a few loose ends. After enough time goes by, members of the team humor him with indulgent baby talk when he says this: “sure it will, man, sure it will. In a week, everything will be great, this will all be behind us, and we’ll celebrate with steaks and lobster at the finest restaurant in town.”

Spoiler alert. At the end of Steinbeck’s novel, the idyllic rabbit farm exists only in the mind of one of the friends, shortly before he’s shot in the back of the head by the other, in an act that is part merciful euthanasia and part self-preservation. The corporate equivalent of this is what eventually happens to our project manager. Every week he insists that everything will be fine and that they’re pretty close to the promised land until someone puts the project out of its misery.

Shooting-Star-Driven Development (SSDD)

Steinbeck-Driven Development is not for everyone. It requires a healthy ability to live in deluded fantasy land (or, in the case of the novel, to be a half-wit). SSDD project managers are not the relentless optimists that their SDD counterparts are. In fact, they’re often pretty maudlin, having arrived at a PM post on a project that everyone knows is headed for failure and basically running out the clock until company bankruptcy or retirement or termination or something. These are the equivalents of gamblers that have exhausted their money and credit and are playing at the penny tables in the hopes that their last few bucks will take them on an unprecedented win streak. Or, perhaps more aptly, they’re like a lonely old toy-maker, sitting in his woodshop, hoping for a toy to come to life and keep them company.

This PM and his project are doomed to failure, so he rarely bothers with status meetings, creates a bare minimum of power points, and rarely ever talks about milestones. Even his Gantt charts have a maximum of three nested dependencies. It’s clear to all that he’s phoning it in. He knows it’s unlikely, but he pins his slim hope to a shooting star: maybe one of his developers will turn out to be the mythical 100x developer that single-handedly writes the customer information portal in the amount of time that someone, while struggling to keep a straight face, estimated it would take to do.

As projects go along and fall further and further behind schedule and the odds of a shooting star developer become more and more remote, the SSDD project manager increasingly withdraws. Eventually, he just kind of fades away. If Geppetto were a real life guy, carving puppets and asking stars to make them real children, he’d likely have punched out in an 19th century sanitarium. There are no happy endings on SSDD projects–just lifeless, wooden developers and missed deadlines.

Fear-Driven Development (FDD)

There is no great mystery to FDD projects. The fate of the business is in your hands, developers. Sorry if that’s a lot of pressure, but really, it’s in your hands.

The most important part of a FDD project is to make it clear that there will be consequences–dire consequences–to the business if the software isn’t delivered by such and such date. And, of course, dire consequences for the business are pretty darned likely to affect the software group. So, now that everyone knows what’s at stake, it’s time to go out and get that complex, multi-tiered, poorly-defined application built in the next month. Or else.

Unlike most waterfall projects, FDD enters the death march phase pretty much right from the start of coding. (Other waterfall projects typically only start the death march phase once the testing phase is cancelled and the inevitability of missing the deadline is clear.) The developers immediately enter a primal state of working fourteen hours per day because their very livelihoods hang in the balance. And, of course, fear definitely has the effect of getting them to work faster and harder than they otherwise would, but it also has the side effect of making the quality lower. Depending on the nature of the FDD project and the tolerance level of the customers for shoddy or non-functional software, this may be acceptable. But if it isn’t, time for more fear. Consequences become more dire, days become longer, and weekends are dedicated to the cause.

The weak have nervous breakdowns and quit, so only the strong survive to quit after the project ends.

Passive-Aggressive-Driven Development (PADD)

One of the most fun parts of waterfall development is the the estimation from ignorance that takes place during either the requirements or design days. This is where someone looks at a series of Visio diagrams and says, “I think this project will take 17,388.12 man-hours in the low risk scenario and 18,221.48 in the high-risk scenario.” The reason I describe this as fun is because it’s sort of like that game you play where everyone guesses the number of gumballs in a giant jar of gumballs and whoever is closest without going over wins a prize. For anything that’s liable to take longer than a week, estimation in a waterfall context is a ludicrous activity that basically amounts to making things up and trying to keep a straight face as you convince yourself and others that you did something besides picking a random number.

Well, I broke this task up into 3,422 tasks and estimated each of those, so if they each take four hours, and everything goes smoothly when we try to put them all together with an estimate for integration of… ha! Just kidding! My guess is 10,528 hours–ten because I was thinking that it’d have to be five digits, the fve because it’s been that many days that we’ve been looking at these Gantt charts and sequence diagrams, and twenty-eight because that was my number in junior high football. And you can’t bid one hour over me because I’m last to guess!

But PADD PMs suck all of the fun out of this style of estimation by pressuring the hours guessers (software developers) into retracting and claiming less time. But they don’t do it by showing anger–the aggression is indirect. When the developer says that task 1,024, writing the batch file import routine, will take approximately five hours, the PADD PM says, “Oh, wow. Must be pretty complicated. Jeez, I just assumed that a senior level developer could bang that out in no more than two. My bad.” Shamed, the developer retracts: “No, no–you’re right. I figured the EDI would be more complicated than it was, so I just realized that my estimate is actually two hours.”

Repeated in aggregate, the PADD PM is some kind of spectacular black belt/level 20/guru/whatever metric is used to measure PM productivity, because he just reduced the time to market by 60% before a single line of code was ever written. Amazing! Of course, talk at the beginning of the project is cheap. The real measure of waterfall project success is figuring out who to blame and getting others to absorb the cost when the project gets way behind schedule. And this is where the PADD master really shines.

To his bosses, he says, “man, I guess I just had too much faith in our guys–I mean, I know you hire the best.” To the developers, he says, “boy, your estimates seemed pretty reasonable to me, so I would have assumed that everything would be going on time if you were just putting in the hours and elbow grease… weird.” To the end-users/stakeholders, he says, “it’s strange, all of our other stakeholders who get us all of the requirements clearly and on time get their software on time–I wonder what happened here.”

There’s plenty of blame to go around, and PADD PMs make sure everyone partakes equally and is equally dissatisfied with the project.