docs: update .editorconfig and reformat readmes

This commit is contained in:
Ilkka Seppälä
2024-03-31 18:01:06 +03:00
parent dfd34d890b
commit de5a93c499
31 changed files with 387 additions and 985 deletions
+17 -43
View File
@@ -16,37 +16,25 @@ tag:
## Intent
The Component design pattern aims to organize code into reusable, interchangeable components, promoting flexibility and
ease of maintenance in game development by allowing entities to be configured with varying behaviors.
The Component design pattern aims to organize code into reusable, interchangeable components, promoting flexibility and ease of maintenance in game development by allowing entities to be configured with varying behaviors.
![Intent](./etc/component.duplication.png "Component Design Pattern")
## Explanation
Real world example
> Suppose your video game consists of a graphics component and a sound component. Including the methods and attributes
> of both of these features in a single java class can be problematic due to many reasons. Firstly, the graphics and sound
> code can create an extremely long java class which can be hard to maintain. Furthermore, graphics components may be
> written and implemented by a separate team as to the sound contents. If both parties work simultaneously on the same
> java class, this may cause conflicts and major delay. Using the component design pattern, the development team is able
> to create individual component classes for graphics and sound whilst providing the domain/object the reach to both of
> these attributes.
> Suppose your video game consists of a graphics component and a sound component. Including the methods and attributes of both of these features in a single java class can be problematic due to many reasons. Firstly, the graphics and sound code can create an extremely long java class which can be hard to maintain. Furthermore, graphics components may be written and implemented by a separate team as to the sound contents. If both parties work simultaneously on the same java class, this may cause conflicts and major delay. Using the component design pattern, the development team is able to create individual component classes for graphics and sound whilst providing the domain/object the reach to both of these attributes.
In plain words
> The component design pattern provides a single attribute to be accessible by numerous objects without requiring the
> existence of a relationship between the objects themselves.
> The component design pattern provides a single attribute to be accessible by numerous objects without requiring the existence of a relationship between the objects themselves.
Key drawback
> With the implementation of the component design pattern, it can be very difficult to create a relationship
> between components. For example, suppose we require the sound component to be aware of the current animation in order
> create a certain sound based upon the animation; this can be quite tricky as the component design pattern makes
> components 'unaware' of other components' existence due to its decoupling nature.
> With the implementation of the component design pattern, it can be very difficult to create a relationship between components. For example, suppose we require the sound component to be aware of the current animation in order create a certain sound based upon the animation; this can be quite tricky as the component design pattern makes components 'unaware' of other components' existence due to its decoupling nature.
**Programmatic Example**
The App class creates a demonstration of the use of the component pattern by creating two different objects which
inherit a small collection of individual components that are modifiable.
The App class creates a demonstration of the use of the component pattern by creating two different objects which inherit a small collection of individual components that are modifiable.
```java
public final class App {
@@ -68,9 +56,7 @@ public final class App {
}
```
Much of the program exists within the GameObject class, within this class, the player and NPC object create methods are
set up. Additionally, this class also consists of the method calls used to update/alter information of the object's
components.
Much of the program exists within the GameObject class, within this class, the player and NPC object create methods are set up. Additionally, this class also consists of the method calls used to update/alter information of the object's components.
```java
public class GameObject {
@@ -119,9 +105,7 @@ public class GameObject {
}
```
Upon opening the component package, the collection of components are revealed. These components provide the interface
for objects to inherit these domains. The PlayerInputComponent class shown below updates the object's velocity
characteristic based on user's key event input.
Upon opening the component package, the collection of components are revealed. These components provide the interface for objects to inherit these domains. The PlayerInputComponent class shown below updates the object's velocity characteristic based on user's key event input.
```java
public class PlayerInputComponent implements InputComponent {
@@ -159,10 +143,8 @@ public class PlayerInputComponent implements InputComponent {
## Applicability
* Used in game development and simulations where game entities (e.g., characters, items) can have a dynamic set of
abilities or states.
* Suitable for systems requiring high modularity and systems where entities might need to change behavior at runtime
without inheritance hierarchies.
* Used in game development and simulations where game entities (e.g., characters, items) can have a dynamic set of abilities or states.
* Suitable for systems requiring high modularity and systems where entities might need to change behavior at runtime without inheritance hierarchies.
## Known Uses
@@ -173,28 +155,20 @@ public class PlayerInputComponent implements InputComponent {
Benefits:
* Flexibility and Reusability: Components can be reused across different entities, making it easier to add new features
or modify existing ones.
* Decoupling: Reduces dependencies between game entity states and behaviors, facilitating easier changes and
maintenance.
* Dynamic Composition: Entities can alter their behavior at runtime by adding or removing components, providing
significant flexibility in game design.
* Flexibility and Reusability: Components can be reused across different entities, making it easier to add new features or modify existing ones.
* Decoupling: Reduces dependencies between game entity states and behaviors, facilitating easier changes and maintenance.
* Dynamic Composition: Entities can alter their behavior at runtime by adding or removing components, providing significant flexibility in game design.
Trade-offs:
* Complexity: Can introduce additional complexity in system architecture, particularly in managing dependencies and
communications between components.
* Performance Considerations: Depending on implementation, may incur a performance overhead due to indirection and
dynamic behavior, especially critical in high-performance game loops.
* Complexity: Can introduce additional complexity in system architecture, particularly in managing dependencies and communications between components.
* Performance Considerations: Depending on implementation, may incur a performance overhead due to indirection and dynamic behavior, especially critical in high-performance game loops.
## Related Patterns
* [Decorator](https://java-design-patterns.com/patterns/decorator/): Similar concept of adding responsibilities
dynamically, but without the focus on game entities.
* [Flyweight](https://java-design-patterns.com/patterns/flyweight/): Can be used in conjunction with the Component
pattern to share component instances among many entities to save memory.
* [Observer](https://java-design-patterns.com/patterns/observer/): Often used in Component systems to communicate state
changes between components.
* [Decorator](https://java-design-patterns.com/patterns/decorator/): Similar concept of adding responsibilities dynamically, but without the focus on game entities.
* [Flyweight](https://java-design-patterns.com/patterns/flyweight/): Can be used in conjunction with the Component pattern to share component instances among many entities to save memory.
* [Observer](https://java-design-patterns.com/patterns/observer/): Often used in Component systems to communicate state changes between components.
## Credits