Design Patterns. Finding the best strategy to win.

26 Apr 2022

Design patterns: Strategies to Win

Looking at design patterns, it’s hard for me to remember them or know them by just, well, memorizing them. However, when I look at it through the lens of game strategies or team compositions in video games it becomes easier. One game I want to use to make things easier for me is Counter-Strike.

csgo WP

In Counter-Strike, there are many strategies that teams do in order to gain advantages in order win the round. These strategies have their pros and cons, similar to design patterns. Certain maps (problems) call for certain strategies (design patterns).

Peeking: The Observer Pattern

One pattern I would compare to one of the best strategies in Counter-Strike is to peek down a popular crossing area to get information on the opposing team. This is similar to the Observer design pattern that I used in my code. Like peeking, the Observer design pattern allows the system to react to the changes in data and the system reacts to what changes in the data. An example of this is in my final project of Rainbow Warrior Connection. We have users who are updating their profile or companies who will post jobs. The Observer design pattern allows the website to create new cards with information or delete information when the users ask for it.

Front Controller: Taking control of the Game State

Another pattern I can easily memorize through the uses of games I play is the Front Controller and League of Legends.

LoL WP

In League of Legends, there is something called tempo where a team controls the pacing of the game so they can get objective in order to get stronger. Which then leads the team to win. In Front Controller pattern design, we have certain things happen when an objective or an action has occurred. An example of this is from our final project, when a user logs into our website, they are given a new homepage depending if they are a student or company.

Factory Design: Zerg Rush

SC2 WP

When I think of the Factory Design pattern, I think of Starcraft II. In Factory Design, we make objects and associate them with different classes. And similarly to having multiple objects associate with different classes, in Starcraft II there are different races you can play as and then there are multiple units to build. And with all of those multiple units, there are many things these units can do which can make things overly complicated like in Factory design.

Conclusions

Pattern Design is something that is important in software engineering. For me, it’s hard to memorize these patterns by themselves. But by using games I know to compare these patterns to strategies familiar to me, I’m able to comprehend the different patterns and its uses in certain situations.