Way to Save Your Time

28 Apr 2020

In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. Building a program is just like putting items into an empty room. The easiest way to do it is that directly put them inside the room. However, after putting too many items in the room, it becomes very difficult for us if we want to find something or make a change of a certain item. Therefore, some boxes may be very helpful. If we put some kind of items into the same box, then when we want to find this item we can directly go to that box and find that item easily. Learning of design patterns is like learning the rules of using these boxes to hold items. Actually, we all may have used some design patterns in our coding experiences already.

click

Observer Pattern

It is a very common pattern, and I used it a lot. In this pattern, whenever an object changes its state, its dependencies can get notification about it. This pattern is very important in coding. It is like applying for financial aid, and many students are waiting for their results. If all students don’t know when the application will be approved, and they have to call the financial aid office once a week, then the financial aid office will have a large amount of work to handle. The solution is when the result is ready, the financial aid office can call all students to let them know the result. The most common example is the event listener. The OnClick of a button can send notification of the state of the button to other objects to let them make a change of it.

MVC

MVC

Module-View-Controller pattern is another pattern that I will use all the time. It separates programming into two parts: module and view, and these two parts are independent but working together because a controller can control these two parts. This pattern is used everywhere, all companies are designing programs in this way. They separate the task to UI design and database so two groups of programmers can work on their own and focus on their part of the task.

Decorator pattern

The decorator pattern is a design pattern that allows behavior to be added to an individual object without affecting the behavior of other objects from the same class. For example, all ICS students took ICS111 and Bob also took Music class. In order to change the state of Bob, we can use the Decorator pattern to add a music class to his file without changing other ICS students’ files. This pattern is very common in programming because we always try to add functionality to a special object only.

Conclusion

The design Pattern is very useful most time. Because programmers can find inspiration and solution for a problem that they struggling for a long time. Design patterns are just organizing the pattern of coding which many programmers already applying them in their coding life. It gives these useful solutions a name so next time other programmers who are facing a similar problem can modify these solutions to solve their problems. Therefore, learning design patterns is very significant for programmers.