Category Archives: AntiPatterns

Encapsulation: You’re Doing It Wrong

Encapsulation, or Information Hiding, is one of the core principles of object oriented software development. It ranks up there with Cohesion, Polymorphism, Inheritance and all the other OO things we all hear about and learn about. Unfortunately, many of the … Continue reading 

Also posted in Principles and Patterns | 17 Comments

I Use Inheritance And I’m Not Entirely Ashamed Of It. Should I Be?

Some time ago I saw a video of Dave Thomas at the Scotland On Rails 2009 event. In this video he says something along the line of “Inheritance is the work of the devil. You should not be using it, … Continue reading 

Also posted in Principles and Patterns, Ruby | 15 Comments

Mocks, Stubs and Unreadable Tests: Clearly I’m Doing This Wrong

I tweeted this a few minutes ago: This is in reference to a horrible test that I wrote today. It’s got 2 assertions and more than 20 lines of context to set up the mocks that I needed, to isolate … Continue reading 

Also posted in Principles and Patterns, Quality, RSpec, Test Automation, Testing, Unit Testing | 19 Comments

A Response To “What Is An Interface” By John Sonmez

this started out as a very lengthy reply to john sonmez’ post on What Is An Interface. There’s enough that I want to say that I think it warrants me posting on my blog instead of blogging in his comment … Continue reading 

Also posted in .NET, C#, Principles and Patterns, Unit Testing | 7 Comments

Easy To Read != Easy To Understand

I ran into this code a while back: 1: public abstract class ScanPrefixSpecification : IScanSpecification 2: { 3: public abstract IEnumerable<string> BarcodePrefixesFilter { get; } 4: 5: public bool IsSatisfiedBy(string item) 6: { 7: return BarcodePrefixesFilter.Where(item.StartsWith).Any(); 8: } 9:  10: … Continue reading 

Also posted in Analysis and Design | 4 Comments

Violations Of The “Tell, Don’t Ask” and “Don’t Repeat Yourself” Principles?

In the last few years, I’ve written a lot of code that looks like this: 1: public class IsThisATellDontAskViolation 2: { 3: public void DoBadThings() 4: { 5: if (something.CanHandle(anotherThing)) 6: { 7: var response = something.GetThatFromIt(anotherThing); 8: DoSomethingWithTheResponse(response); 9: … Continue reading 

Also posted in .NET, Analysis and Design, C#, Principles and Patterns | 25 Comments

The Dangers Of AutoMocking Containers

Louis Salin commented on my original post about the Ninject.RhinoMocks automocking container, and brought up a very good point. Here is his comment, reproduced in full: I’ve heard (or read…) that automocking is equivalent to taking weight loss pills while … Continue reading 

Also posted in .NET, Analysis and Design, AutoMocking, C#, Craftsmanship, Quality | 5 Comments

DRY Violations May Indicate A Missed Modeling Opportunity

In a previous blog post, I talked about some potential options for modeling an “item selected” event and a “item de-selected” event. In that post, I suggested a couple of options and stated which one I thought was the right … Continue reading 

Also posted in .NET, Analysis and Design, C#, Principles and Patterns | 1 Comment

My #LSSC10 Presentation And Experience: “Assumptions Are Risks We Have Accepted”

During the 2nd day’s keynote speech at the Lean Software & Systems Conference (#LSSC10), Bob Charette had the title quote of this post in his slides and his speech. There’s no better way to learn a principle like this than … Continue reading 

Also posted in Community, Continuous Improvement, Kanban, LSSC | 2 Comments

Expressive Code: Good Variable Names Instead Of Magic Values And Calculations

I like to remind myself of these little principles that I take for granted, now and then. It’s good habit to get back to basics and really understand why you hold principles so that you can judge whether or not … Continue reading 

Also posted in .NET, Analysis and Design, C#, Craftsmanship, Principles and Patterns | 9 Comments