I was a little confused when I saw the design patterns. Looking back on the study of this semester, it seems that I don’t know much about it. After watching the professor’s video, I realized that we use it all the time. So what exactly are design patterns?Christopher Alexander says, “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice”. According to this concept, my understanding of design patterns is that we can think of design patterns as decorating a house. Imagine that we are designers, and every day we encounter many different clients who want to decorate their houses, and they all have their own favorite styles or preferences. So, how to design a comfortable house for every family. This is a question we face every day as designers. However, every family will need a living room, kitchen, bathroom, bedroom… These are the recurring “patterns” in the environment. Now, the “core” of the solution to this problem may be something like this: a home’s living room needs enough space for people to communicate, the kitchen and bathroom need to be airy and bright, the bedroom needs to feel relaxed and well rested, and the appropriate furniture layout to create a warm atmosphere of home. This is our design pattern - a template for a solution. However, every time we design a house for a client, we adjust this template based on the specific needs of the family, the style of the house and other factors. So, even though we design houses every day, we don’t design two houses with the same decoration. Although we use the same design pattern every time, the way we implement it varies depending on the actual situation.
For a recent ongoing group project, our team adopted the Meteor framework, which has some common design patterns. For example, the publish-subscribe pattern, in which we define a series of publications, like, Meteor.publish('posts.byCountry', function (countryName) {return Posts.collection.find({countryRegion: countryName }); });
This allows a client to subscribe to post data for a specific country or region. The client subscribes using Meteor.subscribe('posts.byCountry', 'CountryName');
to fetch this data and the UI updates in real-time with new data. This pattern allows our system to update automatically, and when there is a change on the client side, the system will update on its own, so we don’t have to do anything manually. We also used the observer pattern. For example, in the ListPostUser page, we use Meteor’s useTracker hook to subscribe to and respond to changes to the Posts collection. When the content of the Posts collection changes, useTracker automatically runs and updates the UI to ensure that users see the most up-to-date information. In our project, the Front Controller design pattern is embodied in the routing package: react-router-dom in the App.js. By using the
Design patterns play a crucial role in software engineering. It deepens our understanding of software design and becomes an invaluable tool when we encounter challenges. Just as design patterns guide us in decorating a house, they can also guide us to build more powerful and flexible software engineering solutions