Skip to content

Comments

Replace magic numbers and strings with named constants across all implementations#25

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/create-solution-for-issue-23
Draft

Replace magic numbers and strings with named constants across all implementations#25
Copilot wants to merge 5 commits intomainfrom
copilot/create-solution-for-issue-23

Conversation

Copy link

Copilot AI commented Nov 21, 2025

Issue #23 requested elimination of magic numbers and strings from the codebase.

Changes

Replaced hardcoded values with named constants across 15 language implementations (Python, Java, TypeScript, C#, Go, Ruby, Swift, Kotlin, C++, C, PHP, Elixir, Common Lisp):

Numbers → Constants:

  • 1.0DEFAULT_ITEM_QUANTITY
  • 2, 3, 5TWO_FOR_AMOUNT_QUANTITY, THREE_FOR_TWO_QUANTITY, FIVE_FOR_AMOUNT_QUANTITY
  • 100.0PERCENTAGE_DIVISOR
  • 40DEFAULT_COLUMNS (receipt printer)

Strings → Constants:

  • "3 for 2"THREE_FOR_TWO_DESCRIPTION
  • "2 for "TWO_FOR_PREFIX
  • " for "FOR_SEPARATOR
  • "% off"PERCENT_OFF_SUFFIX
  • "Total: "TOTAL_LABEL (receipt printer)

Example (Python)

Before:

def add_item(self, product):
    self.add_item_quantity(product, 1.0)

# ...
if quantity_as_int >= 2:
    discount = Discount(p, "2 for " + str(offer.argument), -discount_n)

After:

DEFAULT_ITEM_QUANTITY = 1.0
TWO_FOR_AMOUNT_QUANTITY = 2
TWO_FOR_PREFIX = "2 for "

def add_item(self, product):
    self.add_item_quantity(product, DEFAULT_ITEM_QUANTITY)

# ...
if quantity_as_int >= TWO_FOR_AMOUNT_QUANTITY:
    discount = Discount(p, TWO_FOR_PREFIX + str(offer.argument), -discount_n)

No behavioral changes. All existing tests pass.

Original prompt

Create a solution for issue #23


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 21, 2025 10:29
…ntations

Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
…ions

Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
Copilot AI changed the title [WIP] Create solution for issue #23 Replace magic numbers and strings with named constants across all implementations Nov 21, 2025
Copilot AI requested a review from nstubbe November 21, 2025 10:46
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.

2 participants