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

Suboptimal Implementation of Status Codes #8

Open
Bryce-3D opened this issue Apr 29, 2024 · 0 comments
Open

Suboptimal Implementation of Status Codes #8

Bryce-3D opened this issue Apr 29, 2024 · 0 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@Bryce-3D
Copy link
Owner

Currently it is annoying to have to use a chain of if and elif statements to handle the TTTStatusCodes.

Rough suggestion by htns to use polymorphism instead

@abstract
class Response:
    @abstract
    def getMessage()->str: …

class SuccessResponse(Response):
    def getMessage()->str:
        actual implementation here

class NotInLobbyResponse(Response):
    def getMessage()->str:
        actual implementation here

class Lobbies:
    def place(…) → Response:
        if …:
            return SuccessResponse(…)
        else:
            return NotInLobbyResponse(…)
@Bryce-3D Bryce-3D added the good first issue Good for newcomers label Apr 29, 2024
@Bryce-3D Bryce-3D self-assigned this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant