Skip to content

Conversation

@cmorman89
Copy link
Owner

@cmorman89 cmorman89 commented Jan 4, 2025

[REFACTOR] Update NyxEngine as a singleton that holds instances for main subclasses

Overview

The NyxEngine class has been updated to be a singletime that holds instances for the main
subclasses. This change was made to simplify the process of accessing the main subclasses and to
ensure that only one instance of each subclass is created.

Now any class that needs to access the main subclasses can do so by calling the NyxEngine class,
which brings along with it the correct instances of the main subclasses.

This solves:

  • The need to pass the main subclasses around as parameters (which becomes cumbersome as the
    project grows).
  • Ensuring state consistency across the project by having only one instance of each main subclass
    and only "allowing" them to be created in the NyxEngine class.
  • Using class attributes to store subclass data; now the NyxEngine class is responsible for
    managing the instances of the main subclasses and providing them to other classes.

Changes Made

Changes were fairly widespread across the project, but the main changes were made were:

  • Refactoring the NyxEngine class to be a singleton.
  • Updating the main subclasses to be created and stored in the NyxEngine class' instance.
  • Removing class attributes from the main subclasses and updating the classes that used them to
    access the instances from the NyxEngine class.
  • Adding error-checking to the TermUtils class to gracefully handle when operating outside of a
    terminal environment.
  • Update tests to reflect the changes made to the main subclasses.

Closes #37, #38

@cmorman89 cmorman89 added enhancement New feature or request nyx-engine labels Jan 4, 2025
@cmorman89 cmorman89 self-assigned this Jan 4, 2025
@cmorman89 cmorman89 marked this pull request as ready for review January 4, 2025 04:42
@cmorman89 cmorman89 merged commit 163a452 into develop Jan 4, 2025
2 checks passed
@cmorman89 cmorman89 deleted the feature/singleton-engine branch January 8, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request nyx-engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Remove Class-Level Attributes [FEATURE] Singleton NyxEngine Class

2 participants