Design Pattern is a generic repeatable solution to a typically occurring problem in software design in software engineering. It is a template for solving an issue that may be applied to a variety of scenarios. In many video games I play, a design pattern is utilized in the development and building of the app.
Table code from this website
Purpose | Design Pattern | Aspect(s) that can vary |
---|---|---|
Creational | Abstract Factory | families of product objects |
Builder | how a composite object gets created | |
Factory Method | subclass of object that is instantiated | |
Prototype | class of object that is instantiated | |
Singleton | the sole instance of a class | |
Structural | Adapter | interface to an object |
Bridge | implementation of an object | |
Composite | structure and composition of an object | |
Decorator | responsibilities of an object without subclassing | |
Facade | interface to a subsystem | |
Flyweight | storage costs of objects | |
Proxy | how an object is accessed; its location | |
Behavioral | Chain of Responsibility | object that can fulfill a request |
Command | when and how a request is fulfilled | |
Interpreter | grammar and interpretation of a language | |
Iterator | how an aggregate's elements are accessed, traversed | |
Mediator | how and which objects interact with each other | |
Memento | what private information is stored outside an object, and when | |
Observer | number of objects that depend on another object; how the dependent objects stay up to date | |
State | states of an object | |
Strategy | an algorithm | |
Template Method | steps of an algorithm | |
Visitor | operations that can be applied to object(s) without changing their class(es) |
In a game I play, called Genshin Impact, to make your characters stronger is by leveling their level, talents, and artifacts. The most intricate part of Genshin character building is the artifacts stats and artifact sets that can be given to each character. Each artifact stat, artifact substats, character level, and character talent level will affect the damage output of your character.
The simplest formula for calculating damage, ignoring character buffs and critical hits, is:
ATK = Attack DMG = Damage RES = Resistance DEF = Defense
Non-critical Hit = ATK Power * Skill% * Enemy Damage Reduction * DMG Bonus% * (1 - RES%)
ATK Power = [(Character's Base ATK + Weapon ATK) * (1 + Weapon ATK% bonuses + Artifact ATK% bonuses)] + Artifact ATK flat bonuses]
Enemy Damage Reduction = (Character Level + 100) / [(Enemey Level + 100) + (Character Level + 100)]
Just from calculating raw damage of a character, many design patterns is utilized such as builder, composite, and mediator. Building a character by leveling them and giving them strong artifacts represents the builder pattern. Composite pattern is represented by the artifact and the stats that it provides to a character. Mediator is represented by how all these numbers are used in a formula to calculate raw damage. The complexity of the damage gets more complicated when factoring in elemental reactions, elemental mastery, party resonnance, and reduced resistances.
In our final project, Warrior Cravings, design patterns are present. The Front controller design pattern is used when a user logs in, and depending on the access level of their account, different links will be displayed and allowed only with a certain accesss level. An example of the publish-subscribe design patern used at the vendor access level, is when creating new menu items, the page will update using React components.
Design Patterns are very important in Software Engineering and when implemented correctly, design patterns may speed up the development process while also lowering the risk of mistakes.