Skip to content

Experiments public contract#243

Merged
wzieba merged 23 commits intoexperimentation_refactorfrom
experiments_public_contract
Sep 5, 2024
Merged

Experiments public contract#243
wzieba merged 23 commits intoexperimentation_refactorfrom
experiments_public_contract

Conversation

@wzieba
Copy link
Member

@wzieba wzieba commented Aug 29, 2024

Description

This PR introduces improvements to the public contract:

  • extracts an interface: VariationsRepository, so the clients can easily double this in tests + KDoc comments
  • introduces a behavior change: refreshing cache on SDK initialization, as I believe this is something that every client would do on initialization anyway
  • simplifies refresh API (no need for two methods)
  • adds README.md with an explanation about how to use the SDK

Testing

The only behavior change has been covered with automated tests. It's still possible to smoke test using instructions from #241 , if necessary.

wzieba added 10 commits August 29, 2024 09:19
Because this is what ExPlat practically is - a repository for `Variation`.

Extracting an interface makes it easier for consumers to introduce a test double for this
…method

This was it's more readable IMO and is similar to how other systems work (especially in CMD) - the operation is requested and can perform the action or not depending on circumstances. But it also has a `-f` parameter.
So we can be aware of any changes to the public contract.
I don't think `interface` is very useful here. Value class is just fine and makes the API cleaner
We want SDK to provide easy API, and not bother clients with necessary requests (like calling `refresh` manually on every initialization)
@wzieba wzieba requested a review from ParaskP7 August 29, 2024 11:05
@wzieba wzieba marked this pull request as ready for review August 29, 2024 11:05
public class ExPlat internal constructor(
private val platform: String,
private val experiments: Set<Experiment>,
experiments: Set<Experiment>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder: is there a value in providing experiments in the constructor and then checking for its existence in getVariation? I don't see good benefits 🤔

Copy link
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And with that final review, I think I am done with all the review @wzieba , kudos on this work, it will help our product teams setup and start using ExPlat without much overhead, and mostly, without FluxC! 🎉 🥇 🚀

Let's start resolving the comments one-by-one and merge everything to trunk when ready, just let me know how to help you from here! 💯

plugins: [$CI_TOOLKIT]
command: |
cp gradle.properties-example gradle.properties
./gradlew :experimentation:apiCheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise (❤️): Awesome, love it, thanks for adding the binary-compatibility-validator plugin into this repo, let's start using this more and more within this project and other repos as well! 🥇

@@ -0,0 +1,63 @@
# Experimentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise (❤️): Thanks for creating a README.md to help with the API usage!

*
* Should be a Singleton, as it keeps track of the "active" [Variation]s. See [getVariation] for more details.
*/
public interface VariationsRepository {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise (❤️): Love it! 🥇

Base automatically changed from improve_threading_and_test_suite to experimentation_refactor August 30, 2024 12:14
wzieba added 8 commits August 30, 2024 14:15
This commit adds a new class: `CacheDto` that saves previously saved data with addition to `anonymousId`. This additional field will be used for cache validation.
The `initialize` method now takes a mandatory `anonymousId` parameter and is responsible for setting the anonymous identifier and triggering the initial assignment refresh and cache validation if `anonymousId` is different
I came to a conclusion, that `refresh` is not needed for the client: SDK should on its own manage the state of the cache and not delegate additional responsibility to SDK consumer.

The cache is refreshed whenever needed during initialization
As SDK doesn't offer refreshing anymore, we don't need to use internal-only `RefreshStrategy`. Refactor seems successful as unit tests are still passing without any changes
If ExPlat was not initialized, log or throw an exception for quicker debugging
@wzieba wzieba merged commit 4579d76 into experimentation_refactor Sep 5, 2024
@wzieba wzieba deleted the experiments_public_contract branch September 5, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants