The 5 Ways to Improve Your Software Quality: Design Patterns

January 21, 2014

By Steve Mezak

Design_PatternsThere are five ways to improve software quality, and this post focuses on design patterns.

A design pattern simply takes the solution from a previous problem and applies the concepts from that solution to solve a new problem.

 

I recently moved into a new house, and in my new home office, there is area section of floor made of rough stone, which once was under a wood stove. I thought this area would be an ideal place for bookcases, except the rough surface was too uneven. I came up with numerous ideas to try and fix this, including ones that required putty and sand, but none of my ideas were as fool-proof as what a carpenter finally suggested. The carpenter explained how to plane wood and utilize shims to solve my problem.

He had a design pattern – a proven process that had solved many other other construction problems. (And you can see my now stable bookcases behind me in our recent software outsourcing videos).

Programmers face similar situations. Problems arise, and if the programmers have never experienced that specific problem before, they might try something akin to my putty-and-sand idea. In the 1990s a group of programmers (called The Gang of 4) recognized this kind of situation and wrote a book about the commonly repeated patterns of object-oriented programming (Java, C++, etc.). They developed a problem-solving catalog for programmers that detailed existing design patterns and the circumstances in which they would want to use those patterns. The Gang of 4 also divulged the consequences of using certain patterns and what limitations they might experience later.

There are three patterns most often used in object-oriented programming.

Publish-Subscribe Pattern

The first is the observer pattern, which is also known as the publish-subscribe pattern.This is a behavioral pattern that watches for changes in one part of the application and then communicates those changes to other objects within the program. This is a dynamic pattern that notifies other systems or objects when changes occur. For example, this is the pattern responsible for updating schedules in response to changes in a “date” field. The observer pattern is looking for behavior in that field and prompts other objects in the code to use that new date.

Factory Pattern

The second type of pattern commonly used in object-oriented programming is the factory pattern. This is considered a creational pattern, because it eliminates the need to write code for each different object that needs to be created. For example, factory patterns are used to create the dialog boxes in Windows and Mac OS. The code in the factory pattern runs a test to determine if it’s running on Windows or running on a Mac. Depending on the answer, it creates the appropriate box in the appropriate way. The pattern simplifies the code, because the pattern creates the dialog boxes in the unique way necessary, without the need to write code for every type of box.

Structural Pattern

This pattern helps organize objects in the code and is especially helpful with combining objects into larger structures.

Professional programmers are expected to know and use design patterns. There are several design pattern resources available that can help programmers develop solutions to new problems – there is no need to try putty and sand. Software developers who use design patterns as part of their organization’s culture greatly enhance the shared knowledge within their software development group, and the quality of the software they develop.

When evaluating a software development service company, ask them about their use of design patterns when developing software for their clients. IT’s one of the things we look for when assessing our global partners.

Subscribe

Learn more about successful outsourcing and get the latest from Accelerance.