-
Last time, in Cooking Up a Good Template Method , I had a template method cooking our dinner. An abstract base class defined the template—the high level steps for preparing a one-skillet dinner—and a derived class provided the implementation for those steps. I'm currently reading Ken Pugh...
-
I was working on cleaning up Albacore this weekend, and I noted that both the NCoverConsole and MSBuild tasks in Albacore both require the location of the .exe, to execute. The MSBuild task defaults itself to the .NET 3.5 SP1 folder, if none is specified, but the NCoverConsole task requires the path...
-
Andrew Woodward recently posted a comparison of his test-driven Prime Factors solution to one written by Uncle Bob . In the comments, someone suggested that Andrew use an iterator instead so I thought I'd give it a try. First, let's repost the original code: private const int SMALLEST_PRIME = 2; public...
-
In the last refactoring challenge , I had a problem with some nasty conditional complexity. To be honest, the challenge was a subtle way to crowdsource new features in AutoMapper, but hey, it worked. One of the hard parts of being a sole contributor to an OSS project is that I lose the benefits...
-
In the previous part to the refactoring challenge, I needed to structure the original implementation to a point where I could start applying other refactorings. Whenever I start to see a bunch of “if” statements or a big switch statement, this is a pretty strong smell that I need to reduce conditional...
-
Other posts in this series: Refactoring challenge – cry for help Part 1 – Examination In the last part of this series, I took a closer look at the code smells found by commenters, which included: No tests Feature envy Conditional complexity Long method All of these code smells can be found in the two...
-
Most of the time I post code on my blog, it’s something I’m proud of. Other times, it’s code I didn’t write, which I promptly lambaste. In my last post , I threw up code I did write, but couldn’t see the design coming out. From the responses, I think I have some direction. But...
-
I don’t like messy, obfuscated code. But occasionally often, I write it anyway as I can’t quite see the right way to go. Today is one of those days where I can’t seem to get past some ugly code, none of my normal tricks seem to work. Instead of me doing any more work on it, I’m curious...
-
Checking out the NerdDinner code the other day, I found a common Dependency Injection anti-pattern. One of the core concepts of DI is that components are not responsible for locating their own dependencies. The code went part of the way to full-on DI, but not quite far enough. Here...
-
Technical debt, even on the agile-ist of agilista teams, still accumulates. Debt is inevitable, as initial design is always based on assumptions, not all of which pan out. I never view that as a failure, as all we can do is make the best decision given the limited information we know at any...
-
Lately my co-worker asked me to pair with him and make a code review with him of one of his projects. After having spent some hours on refactoring this legacy application together with my co-worker I want to share some important lessons learned. I call this application a legacy application because it...
-
In the manufacturing world, you would never find a company that assembles a bunch of parts into a final product before inspecting any of the individual parts, and they would not wait until the end of the assembly line to test for the quality of the product. The very notion of waiting until the product...
-
This post is part of the November 2008 Pablo's Topic Of The Month (PTOM) - Design Patterns and will primarily outline the State pattern, with an Enumeration or Descriptor pattern thrown in for good measure. Switch statements and if-then statements are not object oriented code. They are conditional...
-
In my last post , I talked about the idea of encapsulation and using it to ensure that our business rules were enforced correctly. What I didn't talk about, though, was the second half of the conversation that my coworker and I had, concerning the patent -> consultation relationship. It turns...
-
Yesterday, I was involved two very separate yet very related conversations. One was via twitter with Colin Jack and Jimmy Bogard (which I was only a partial contributor to - mostly just reading their conversation) and another after work with a coworker . The short version of both conversations can be...