Filter By:

folder Software Design

Software Design - Symptoms of Bad Code

today

Admit it, we’ve all written bad code at some point in our software development careers. One could even argue it’s perfectly acceptable to write bad code when the situation calls for it. Bad code is perfect for cranking out minimum viable products, or implementing a last minute fix for a critical bug in production that has management breathing down the back of your neck waiting for a solution. The catch-22 however, is that bad code should only be brought to life when it will have a life-span so short that death is already looming in the shadows waiting to snatch it. Read more...

Software Design - Abstraction

today

The Less You Know, The Better Do you think the automotive designers who carefully crafted each body line and roll of your car’s chassis cared about the engine’s cylinder bore or stroke? Or perhaps the firing order, or whether the engine had 2 spark plugs per cylinder akin to Chrysler’s hemis? Of course not, all they cared about were the more important details such as dimensions, mounting positions, electrical connections, and plumbing points. Read more...

Software Design - Marker Interfaces

today

What Are They? A marker interface is an empty interface (no methods or properties) that is used to identify classes that implement it belong to a special group. Some might argue that this is a code smell, but in certain situations they can be the best solution for constraining types. It should be noted that the purpose of marker interfaces is a perfect job for the decorator pattern. However, in some languages (C# for example) attributes lack the support we need to implement a quick solution. Read more...

Software Design - Magic Numbers

today

What Are They? Magic numbers are numbers in code that appear to be arbitrary, but actually serve a purpose. They are commonly described as an anti-pattern as they diminish code quality, and are “referred to as breaking one of the oldest rules of programming, dating back to the COBOL, FORTRAN and PL/1 manuals of the 1960s”. [1] However, this does not mean that all constants should be blindly replaced with pre-defined constants. Read more...

Software Design - Dependency Injection and Inversion

today

What are they? While it may seem like nothing more than buzz words, dependency injection is a well known principle. In fact, you’ve likely used it yourself in the past and just didn’t know the technique had a name. Dependency injection can be thought of as passing a resource required by a class to the class through one of several means. While the class could instantiate a new instance of the resource itself, by using dependency injection we introduce an easier way to take advantage of dependency inversion. Read more...

Software Design - Unit Tests vs Integration Tests

today

Preface Unit tests and integration tests are designed to serve two different purposes. They are not meant to substitute each other, and each type has a specific focus. However, developers tend to struggle to determine the border that seperates unit tests and integration tests as there is no set hard limit on either one. What is a Unit Test? Unit is somewhat of an ambiguous term, but in this situation it can be thought of as the smallest piece of code that can be isolated from the rest of the program. Read more...

Software Design - Validator Pattern

today

Validating Objects Based on Context It’s quite typical for a Domain Driven Design (DDD) project to need validation for it’s domain models. While it may be sufficient to solve this by adding an IsValid() method to each model, this can cause confusion for the developer by cluttering the model class, and/or by requiring the IsValid() method to be generalized that it covers a large range of validation rules for any situation that may arise. Read more...