Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Server Response Class #11

Merged
merged 1 commit into from
Aug 3, 2024
Merged

Conversation

hankhsu1996
Copy link
Owner

Overview

This PR refactors the Response class to improve consistency and readability in the factory method naming. The changes aim to make the naming scheme more intuitive and self-explanatory, ensuring that the purpose of each method is clear at a glance.

Changes

  • Factory Method Renaming:

    • CreateResult: Used for creating a successful user result response.
    • CreateLibError: Handles library internal errors.
    • CreateUserError: Handles user errors, allowing the user to specify error details.
    • FromUserResponse: Automatically creates either a result or error response based on the JSON object provided by the user.
  • Code Structure:

    • Improved separation of interface and implementation by moving certain function implementations to the .cpp file, which enhances code readability and maintainability.

Benefits

  • Consistency: The new naming conventions provide a more consistent and logical structure, making the code easier to understand and maintain.
  • Clarity: By explicitly naming methods according to their purpose, developers can more easily determine which method to use in different scenarios.
  • Maintainability: The separation of interface and implementation helps to keep the header file focused on the class's public API, improving readability and reducing the risk of introducing errors during future refactoring.

Testing

All existing tests have been updated to reflect the new method names and have been verified to pass.

@hankhsu1996 hankhsu1996 merged commit 69e8bdb into main Aug 3, 2024
4 checks passed
@hankhsu1996 hankhsu1996 deleted the feature/response-refactor branch August 3, 2024 08:25
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