For me design pattern is a difficult topic to understand. Design pattern is an idea of having different templates or models for different goal of coding. The idea of design pattern came from the book also named as Design Patterns that inspired by Christopher Alexander’s A Pattern Language. A brief intro about Design Patterns is that the book is also known as “Gang of Four” book, and there are 23 different patterns of C language that the books mention and each pattern has its advantage and disadvantage. In other word, design pattern is a guide of how people would design their code: write down the idea of how and what task would the code perform, it is good to have this before the real coding. Beginners can follow along the design patterns in order to understand the process of program design, so then they will gain experience of code design. Design pattern is not for C language only, the idea of it can also apply to any other programming.
Here is an example of one of the design patterns, builder pattern. Builder pattern combines small pieces into a big piece. I did a JavaScript assignment about Jamba Juice. The big piece we wanted to create is the customer order. Break down an order will be drink/drinks; more deeper will be showing the size of the drink, drink’s name, price, calories and ingredients, these are the smallest piece we can break down of a drink. By assigning each property a value, like size will be “small”, “medium”, “large”, price and calories will be number with the correspoding unit, name of the drinks and ingredients will be strings that describes the drink. Combines this property will create an object, “drinks”.