ChainSafe / ChainSafe/gossamer

refactor: Consider removing interface database.Database

Open
#3,975 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
454
Forks
144
PR merge metrics
No merged PRs in 30d

Description

## Issue summary

The database.Database interface currently defined in the internal package is not necessary and introduces unnecessary complexity. Following Go best practices, we should use concrete implementations directly instead of defining interfaces when they are not required.

According to Go's best practices, interfaces should be defined by the consumer, not the provider. This helps in keeping interfaces minimal and focused.
- [Code Review Comments: Interfaces](https://go.dev/wiki/CodeReviewComments#interfaces)
- [Effective Go: Interfaces](https://go.dev/doc/effective_go#interfaces)

The database.Database interface is defined in the internal package, making it inaccessible to external modules. This limits its usability and goes against the purpose of having a flexible interface.

Removing the unnecessary interface will simplify the codebase. It will be clearer and more maintainable to use concrete implementations directly.

Directly returning and using concrete implementations aligns with Go's idiomatic practices and avoids the overhead of defining and managing interfaces that are not needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.