Skip to content

Refactor SetConstant to use a lookup table#20

Open
RealRanger wants to merge 1 commit into
MadStudioRoblox:mainfrom
RealRanger:main
Open

Refactor SetConstant to use a lookup table#20
RealRanger wants to merge 1 commit into
MadStudioRoblox:mainfrom
RealRanger:main

Conversation

@RealRanger
Copy link
Copy Markdown

The current implementation of ProfileStore.SetConstant relies on a long if/else chain to assign values. While it works, this approach:

  • Is verbose and harder to maintain
  • Increases the risk of typos

Solution

Refactored ProfileStore.SetConstant to use a private lookup table (_constantSetters) scoped in ProfileStore.

  • Each constant name maps to a setter function that updates the corresponding constant.
  • The rest of the codebase still used the same global constants; no breaking changes.
  • New constants only require one new line in the lookup table.

Benefits

  • Cleaner, more maintainable code
  • Reduced risk of errors when expanding or changing the constants set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant