Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Remove code generation for TweakManager #55

Merged
merged 1 commit into from
May 10, 2021

Conversation

albertodebortoli
Copy link
Member

We realised that TweakAccessorGenerator was trying to be too smart in generating the code for the TweakManager.
When using the configuration with usePropertyWrappers = true it was generating a singleton which is known to be a bad pattern, but we initially thought was somehow good enough for small apps. Needless to say, we do regret such decision. We have now agreed that we don't want to promote such usage and we also can't use it internally in the Just Eat app.
Even without the singleton, the generated accessor wasn't allowing dependency injection in the tweak providers setup code, which is also a limitation we can avoid having. This PR now leaves the user free to setup a TweakManager and inject it into the generated accessor.

@albertodebortoli albertodebortoli force-pushed the remove-code-generation-for-tweak-manager branch from 0052950 to e2e6035 Compare May 7, 2021 08:26
@@ -29,4 +30,36 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window?.rootViewController?.present(alertController, animated: true, completion: nil)
}
}

func makeTweakManager() -> TweakManager {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could make this var tweakManager: TweakManager

Copy link
Member Author

Choose a reason for hiding this comment

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

So it would have to be a lazy var instead of computed property or we would re-create the manager each time (I know, we currently call it only once). Is it really worth it?

tweakProviders.append(\(tweakProviderName))
"""
generatedString.append(tweakProviderAllocation)
private func tweakManagerCodeBlock() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: same here could use var here if you fancied

Copy link
Member Author

Choose a reason for hiding this comment

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

The rest of the file has functions, feels better to keep them all as functions IMHO. The fact that there are no parameters here is less important than having overall consistency in this file I would say.

@albertodebortoli
Copy link
Member Author

Agree with @agroGandhi to proceed with merging this.

@albertodebortoli albertodebortoli merged commit 7fc0391 into master May 10, 2021
@albertodebortoli albertodebortoli deleted the remove-code-generation-for-tweak-manager branch May 10, 2021 09:31
@albertodebortoli albertodebortoli added this to the V6 milestone Jan 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants