这是indexloc提供的服务,不要输入任何密码
Skip to content

Refactor TkClasspathTest for object-oriented exception handling and better expressiveness (relates to #1408) #1436

@niotu

Description

@niotu

Refactor TkClasspathTest for object-oriented exception handling and better expressiveness (relates to #1408)

The test class TkClasspathTest violates several object-oriented design principles discussed in the Pain of OOP course:

  1. Procedural error handling:
    The use of Assertions.assertThrows(...) relies on capturing exceptions with lambdas, which is a procedural approach. Instead, object-based handling using something like TkFailure or RsFailure would align better with object-oriented thinking.

  2. Low-level request construction:
    The test constructs fake requests using raw strings (e.g., "PUT", "/something-else"). This violates the object-oriented idea that everything is an object. Using decorators like RqWithMethod, RqWithUri improves clarity and encapsulation.


Suggested Improvements

  • Replace assertThrows(...) with an object-oriented failure handling strategy where possible.
  • Replace string-based request setup with composable request objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions