Context
I've noticed that the project currently uses some global variables to manage configuration or state in certain modules. While convenient, this can introduce challenges for testing, potential state conflicts, and maintainability.
Proposal
Consolidate the existing global variables into non-global configuration structs, and initialize/pass this configuration using the Options Pattern (also known as Functional Options).
Example Reference
// Proposed usage
client := binance.New(
binance.WithHMAC("apiKey", "secret"),
binance.WithTestnet(),
// ... other configuration options
)
Benefits
- Reduced Side Effects: Explicitly passing dependencies, avoiding implicit global state.
- Improved Testability: Easy to inject different configurations for different test cases.
- Enhanced Readability & Flexibility: Configuration options are passed via explicit function arguments, making code intent clearer and easier to extend with new options.
Next Steps
I would be very happy to implement this change once we reach a consensus.
I'd first like to hear the thoughts of the maintainers and community members:
- Does this direction align with the project's long-term architectural goals?
- Are there any potential concerns we should be particularly mindful of?
Context
I've noticed that the project currently uses some global variables to manage configuration or state in certain modules. While convenient, this can introduce challenges for testing, potential state conflicts, and maintainability.
Proposal
Consolidate the existing global variables into non-global configuration structs, and initialize/pass this configuration using the Options Pattern (also known as Functional Options).
Example Reference
Benefits
Next Steps
I would be very happy to implement this change once we reach a consensus.
I'd first like to hear the thoughts of the maintainers and community members: