Category Archives: DRY

The Model Home

The other day I was having a discussion with my co-worker Justin and came up with an analogy I rather like. I was working on three similar, but slightly different features and first decided to build the foundation for all … Continue reading 

Also posted in Best Practices, Design Principles, Development | 4 Comments

AutoMapper Tests Made Simple

I work primarily on a C# ASP.NET MVC application that deals with many other systems which seem to dish out strings all over the place. Hence the need for something like AutoMapper. When converting this data into objects or enumerations, … Continue reading 

Also posted in AutoMapper, NUnit, Testing | Leave a comment

Comments are the Devil

I recently read Chris Coyier’s article entitled Show Markup in CSS Comments. I was actually a bit angry that so many responses praised this and so few were turned off from the idea. I appreciate the idea of making things … Continue reading 

Also posted in Comments, CSS, Design | 4 Comments

Unit Testing Simple ASP.NET MVC Controllers

I have created enough simple projects using ASP.NET MVC with unit tests to notice a very helpful pattern. The following is a sample of a test fixture using RhinoMocks and NUnit to test a controller. 1: [TestFixture] 2: public class … Continue reading 

Also posted in ASP.NET MVC, Development, Moq, NUnit, RhinoMocks | 6 Comments

Actually Querying with the Specification Pattern

In my previous post, I talked about using the specification pattern for querying collections. I didn’t actually show any code that does what I was talking about, I just showed the set-up and creation of specifications. The following is how … Continue reading 

Also posted in Design Patterns, Moq, Testing | 10 Comments

Using the Specification Pattern for Querying

The specification pattern is great for adhering to the Single Responsibility Principle (SRP). The reason it can be so powerful is that it encapsulates one piece of logic, and nothing more. I’ve decided to come up with some code that … Continue reading 

Also posted in Design Patterns, Design Principles, SOLID | 17 Comments

Anti-Patterns and Worst Practices – Utils Class

If you ever start typing “Utils” or “Utility” stop and think a bit; if you need some help, ask a fellow developer a question of what this code actually does. This anti-pattern is caused either by lack of domain knowledge, … Continue reading 

Also posted in Best Practices, Design Principles | 11 Comments

Anti-Patterns and Worst Practices – The Arrowhead Anti-Pattern

This anti-pattern is named after the shape that most code makes when you have many conditionals, switch statements, or anything that allows the flow to take several paths. You’ll commonly see these nested within each other over and over, thus … Continue reading 

Also posted in Best Practices, Design Principles, Legacy Code | 8 Comments

Anti-Patterns and Worst Practices – You’re Doing it Wrong!

When shown ideal code, I think developers understand why it is favorable. When it is regarding Separation of Concerns (SoC) or Single Responsibility Principle (SRP) the consensus is something along the lines of “of course, that makes sense”. But not … Continue reading 

Also posted in Best Practices, Design Principles, Development, Legacy Code, SOLID, Testing | 22 Comments

A Lesson in DRY Learned with jQuery

While working on a credit card entry form I decided to add a dynamic block of XHTML to highlight the credit card that is entered by the user, while graying out others. In this code, I attempt to retrieve an … Continue reading 

Also posted in jQuery | 5 Comments