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 to use interfaces for improved test mocking and extensibility #6

Open
3 tasks
lucaslopezf opened this issue Aug 15, 2023 · 0 comments
Open
3 tasks

Comments

@lucaslopezf
Copy link
Contributor

lucaslopezf commented Aug 15, 2023

Context:

Currently, the TaskMetrics and ErrorHandlerTask types are defined as a struct. While this serves our immediate needs, it tightly couples our metrics implementation, which can limit our flexibility in the future.

Proposal:

Right now, the way we use (TaskMetrics and ErrorHandler) as a struct works, but it can make changes harder in the future.
We can change the TaskMetrics/ErrorHandler from being a struct to an "interface".

Benefits:

  • Make Testing Easier: With interfaces, making mocks for tests is simpler.
  • Extensibility: By defining the behaviors we expect in an interface instead of being tied to a specific structure implementation, we can add other types in the future without changing existing code.

Next steps:

  • Define two new interfaces: TaskMetricsInterface and ErrorHandlerInterface.
  • Refactor the current TaskMetrics struct to implement the TaskMetricsInterface and the ErrorHandler struct to implement the ErrorHandlerInterface.
  • Update references in our application to use TaskMetricsInterface instead of the TaskMetrics struct and ErrorHandlerInterface instead of the ErrorHandler struct.

🔗 zboto Link

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

No branches or pull requests

1 participant