Design Patterns by Gamma, Helm, Johnson, and Vlissides could possibly be the “holy grail” of software development books. Most practitioners of the software craft have read it and a good many have it sitting on their bookshelves. It has even spawned the “rock star” t-shirt seen here. Robert C. Martin has talked about it, and so has Martin Fowler, Joshua Bloch, Grady Booch, and many others.
Of the design patterns, I would guess that Singleton (127) or Abstract Factory (87) are the most widely used. Perhaps Strategy (315) is also in there somewhere. Not far behind, I would think, is Builder (97). Yet I would argue that Builder (97) is still an underused pattern. I see a lot of code around that would benefit from Builder (97).
By the way, for those of you wondering, yes that is the way these design patterns are commonly notated. The parenthetical number is the page in Design Patterns where the pattern can be found! Builder (97) means the builder pattern, found on page 97 of Design Patterns.
A quick, easy, and widely applicable example of when to use the builder pattern in web development is in form validation. Fair warning, though! It is going to take some time to get around to demonstrating the need for the builder pattern in this example. Read on and we’ll get there, eventually!
Continue reading “Builder (97) Design Pattern, Part 1”