ChainSafe / gossamer

🕸️ Go Implementation of the Polkadot Host
https://chainsafe.github.io/gossamer
GNU Lesser General Public License v3.0
434 stars 121 forks source link

refactor: Consider removing interface database.Database #3975

Open EmilGeorgiev opened 6 months ago

EmilGeorgiev commented 6 months ago

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.

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.

EmilGeorgiev commented 5 months ago

If you think this makes sense, can I take this issue?