A Reusable Solution in Software Engineering

25 Feb 2022

What is the reusable solution?

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
Bridgeimplementation of an object
Compositestructure and composition of an object
Decoratorresponsibilities of an object without subclassing
Facadeinterface to a subsystem
Flyweightstorage costs of objects
Proxyhow an object is accessed; its location
Behavioral Chain of Responsibilityobject that can fulfill a request
Commandwhen and how a request is fulfilled
Interpretergrammar and interpretation of a language
Iteratorhow an aggregate's elements are accessed, traversed
Mediatorhow and which objects interact with each other
Mementowhat private information is stored outside an object, and when
Observernumber of objects that depend on another object; how the dependent objects stay up to date
Statestates of an object
Strategyan algorithm
Template Methodsteps of an algorithm
Visitoroperations that can be applied to object(s) without changing their class(es)

Design Patterns in Genshin Impact

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.

ICS 314 Website Project

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.

My Thoughts

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.