Posts Categorized: Software Development

Object Cesspool Anti-Pattern

Object pools are a common pattern in development. The canonical example is probably a database connection pool. If objects returning to the pool are not validated, the pool can gradually fill with garbage objects, turning it into a cesspool of unusable objects. How to Identify The two easiest ways to identify if your object pool… Read more »

Input Kludge Anti-Pattern

As an anti-pattern, input kludge describes a poor user interface that either rejects or incorrectly handles valid input. How to Identify The most obvious code smell that may point to this pattern is ad-hoc input validation routines. Look for: JavaScript validation function defined directly in web page or view code. Server-side validation routine defined in… Read more »

Code Smells and Anti-Patterns

What is an Anti-Pattern? If you know what a pattern is, then you probably already know about anti-patterns, even if you didn’t know it! In a nutshell, a design pattern is an observed good method to solve a re-occurring problem. You have probably observed patterns in your own development. For instance, maybe you have an… Read more »

Critical Blocks and Improper Lock Objects

Quick catch-up… critical application blocks are blocks of code that can only be executed by one thread at a time. Stock example for illustration: public static class SmackTracker { private static int smackCount = 0; private static object locker = new object();   public static void HitItAgain() { lock (locker) { smackCount++; } } }… Read more »

Order of Operations in nested try..catch..finally

Let’s dive in and take a look at some common and not-so-common exception handling arrangements. Everyone should be familiar with the standard try..catch..finally construct: try { //this code will run only until an exception is thrown } catch { //this code will run only IF and exception is thrown } finally { //this code will… Read more »

Exceptional Introduction

There has been a lot of discussion over the years about when and how to use exception throwing and handling. The general consensusĀ seems to shift every once in a while. The performance of exceptions is not the primary purpose of this article, but I felt the need to discuss it in order to truly address… Read more »