Category Archives: AntiPatterns

Don’t Build A Security System Until There Is Something To Secure

I know a lot of people give credit to the idea of “time to login“. Personally, I don’t think that’s the right way to look at starting an app. (Note: As Joshua Flanagan pointed out in the comments below, I … Continue reading 

Also posted in Bootstrap, Goals, Risk Management, Security | 9 Comments

Embracing Conventions With Namespaced Models And Partials

Six months ago when I started working a contract with Joey Beninghove, I had never done full time rails work. I had played with it a few times and built a few small example apps just to get the hang … Continue reading 

Also posted in Model-View-Controller, Philosophy of Software, Principles and Patterns, Rails, Ruby | 3 Comments

Replacing An If Statement With An Object

I found myself writing this code yesterday: def to_s if status == AssessmentStatus::Open date = get_assessment_short_date(:date_opened) “#{}, Opened #{date}” else date = get_assessment_short_date(:date_closed) “#{}, Closed #{date}” end end   I wrote it and moved on. It worked and it did … Continue reading 

Also posted in Analysis and Design, Principles and Patterns, Ruby | 8 Comments

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