You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: Enhance TCModelFactory with Custom GVL Support and Code Clarity
Currently, TCModelFactory offers two methods for creating TCModel instances: withGVL() and noGVL(). withGVL() generates a TCModel including the GVL, while noGVL() generates one without.
However, the current implementation has a few areas for improvement:
Lack of Custom GVL Support: Both methods implicitly use GVLFactory.getLatest(). There's no way to provide a custom GVL, limiting flexibility for testing and specific use cases.
Confusing noGVL() Parameter: The noGVL() method accepts a TCModel parameter, but its purpose is unclear and seemingly unused. This adds unnecessary complexity and confusion.
Code Duplication and Readability: The logic for creating the base TCModel is duplicated within withGVL() and noGVL(). This hinders maintainability and makes the code harder to understand.
Proposed Solution:
Introduce Custom GVL Parameter: Add an optional gvl parameter (of type GVL) to both withGVL() and noGVL(). If provided, this GVL will be used; otherwise, it defaults to GVLFactory.getLatest().
Remove Unused TCModel Parameter from noGVL(): Eliminate the confusing and unused TCModel parameter from the noGVL() method.
Refactor with Private createBaseTCModel() Method: Extract the shared logic for creating the base TCModel into a private method called createBaseTCModel(gvl?: GVL). Both withGVL() and noGVL() will then call this method, passing the provided or default GVL.
Benefits:
Increased Flexibility: Developers can now use custom GVLs with TCModelFactory, facilitating testing and specific scenarios.
Improved Code Clarity: Removing the unused parameter and refactoring with createBaseTCModel() simplifies the code and makes it easier to understand and maintain.
Reduced Code Duplication: Extracting the shared logic reduces redundancy and improves maintainability.
Example Usage:
// Using the latest GVLconsttcModelWithGVL=TCModelFactory.withGVL();consttcModelNoGVL=TCModelFactory.noGVL();// Using a custom GVLconstmyGVL=// ... your custom GVLconsttcModelWithCustomGVL=TCModelFactory.withGVL(myGVL);consttcModelNoGVLWithCustomGVL=TCModelFactory.noGVL(myGVL);
The text was updated successfully, but these errors were encountered:
Issue: Enhance TCModelFactory with Custom GVL Support and Code Clarity
Currently,
TCModelFactory
offers two methods for creatingTCModel
instances:withGVL()
andnoGVL()
.withGVL()
generates aTCModel
including the GVL, whilenoGVL()
generates one without.However, the current implementation has a few areas for improvement:
Lack of Custom GVL Support: Both methods implicitly use
GVLFactory.getLatest()
. There's no way to provide a custom GVL, limiting flexibility for testing and specific use cases.Confusing
noGVL()
Parameter: ThenoGVL()
method accepts aTCModel
parameter, but its purpose is unclear and seemingly unused. This adds unnecessary complexity and confusion.Code Duplication and Readability: The logic for creating the base
TCModel
is duplicated withinwithGVL()
andnoGVL()
. This hinders maintainability and makes the code harder to understand.Proposed Solution:
Introduce Custom GVL Parameter: Add an optional
gvl
parameter (of typeGVL
) to bothwithGVL()
andnoGVL()
. If provided, this GVL will be used; otherwise, it defaults toGVLFactory.getLatest()
.Remove Unused
TCModel
Parameter fromnoGVL()
: Eliminate the confusing and unusedTCModel
parameter from thenoGVL()
method.Refactor with Private
createBaseTCModel()
Method: Extract the shared logic for creating the baseTCModel
into a private method calledcreateBaseTCModel(gvl?: GVL)
. BothwithGVL()
andnoGVL()
will then call this method, passing the provided or default GVL.Benefits:
TCModelFactory
, facilitating testing and specific scenarios.createBaseTCModel()
simplifies the code and makes it easier to understand and maintain.Example Usage:
The text was updated successfully, but these errors were encountered: