Design Patterns

27 Apr 2019

What is a Design Pattern?

Source

Design patterns are ways to create different possible of solutions to solving a specific problem. With the use of design patterns, software engineers can use this as a template to help their future complications. Using design patterns to help solve your problems can help with readability. Having code that is understandable towards your own colleagues can help you succeed as a software engineer. So. utilizing design patterns and knowing which one to specifically use can help your accomplish tasks more efficiently. Four examples of design patterns are Factory, Singleton, Observer, and MVC patterns. As I was reading through the types of design patterns that were introduced to us, I am guessing we have been using the Singleton design the most and probably moreā€¦

Usage of Design Patterns

The use of design patterns depends on what kind of problem you have encountered. For an example, using factory design pattern can be used to restrict a local variable of a structure of different objects and allow you to make objects without knowing specifically what type you will need in previous code. For singleton design pattern, it is one of the simplest design patterns for modelling. Singleton pattern can be used in many ways and its design can be controversial in terms of time complexity usage. A singleton design pattern should only have one instance. It restricts a class to instantiate multiple objects. Singleton classes should also be globally accessible. This can be useful in situations where the main goal is to coordinate a specific action to a single result. Using the observer design pattern will allow one object to change state to a flexible number of dependent objects which are updated automatically. However, use this method with tightly fixed objects can be difficult to implement, debug, and test because having many objects in occurrence with many different interfaces. Lastly, MVC or model-view-controller pattern is commonly used for creating user interfaces that splits an application to three parts. These three parts are model, view and controller. The entire design revolves on the user. The user would be the one to initiate and the one to receive its results. The MVC design pattern is popular with web developing and used in many programming languages like Java, C#, Python, Ruby, and PHP. The model part of the design manages the data and logic of the entire application. The view part of the design provides the user multiple ways to view the application. The controller does all the conversions in the application and provides a proper result for the user. To conclude design patterns, it is important to be aware of what kind of pattern you are implementing for your application because it will help other developers to understand your product and maybe help improve its functionality in the future.