Sep 27, 2017

Posted by in Home Improvement | Comments Off on Designing Repeat Patterns-A Closer Look

Designing Repeat Patterns-A Closer Look

As a pre-cursor to design patterns in the previous article in this series I looked at common signs to over engineering your design by forcing a design pattern that doesn’t fit. One important point I made was not starting with a design pattern and opting to refactor to one when you know it’s necessary. Not over complicating your design with the noise of trying to fit a pattern into it before you know your design really requires one. If you have taken this approach it is at this point that your design has had some time to incubate on its own; stand, or crumble under its own supports. In the case of crumbling supports you have identified a hole in your design. So what do you do with any hole? Search for the right size shape to plug it! Here’s how.

Describe the hole your design pattern will fill-What type of hole is it that sits in your design? Since you are looking for a design pattern to fill the hole describe the problem as it relates to the three types of design patterns; creational, structural or behavioral. The goal here is to identify and narrow down the list of possible design patterns. So, is your problem a creational one? A Structural one? or a behavioral one? Once you have identified the type you have narrowed the list of options by two thirds. you can try these out

How to identify the problem-Here are some tips on determining what type of problem you have. Creational, if you are trying to separate the process of object construction and object use. Typically patterns like the Singleton, Factory, Abstract Factory and Builder. Structural – If you are trying to interface to a sub-system, connect to an interface your system doesn’t support or provide a flexible storage structure for adding and manipulating objects.. Adapters, Bridges, Composites and Façade’s are good examples. Behavioral, If the primary concern is how you access objects, perform operations on them and otherwise interact with them consider patterns like the Command, Iterator, Observer, Strategy and Visitor. It should be noted that the list above is far from exhaustive. Just an example of what you might be looking for.