Posts

Showing posts from January, 2018

The REAL Builder Pattern

Image
I have been reading about Design Pattern lately, and I ran across some articles about the Builder Pattern that are not accurate at all. Because of that, I decided to write a short article about what this pattern is and how to properly implement it. I will start by providing a short description of what this pattern is. I will follow that with some context by providing hypothetical usages for this pattern, and conclude with a (hopefully good) code example. What is the Builder Pattern? Even these bad articles got one thing right: The Builder Pattern is a Creational Pattern . This means that the pattern's main goal is to provide a reusable solution for creating objects. You may ask, why are there more than one creational pattern? Isn't invoking a class constructor enough? Well... yes and no. Why use Builder Pattern? Experts (people who know more than me) have determined that using one of these creational patterns is preferred over invoking the constructor of a c