Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more legacy
  • Loading branch information
tarrinneal committed Jul 22, 2024
commit f3002f14e6e7ee308acaa9b5360c6d094dde16c9
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you stuck on legacy as the prefix? The meaning of legacy can change over time so v1 might be a better prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think legacy is pretty fitting, as it is now legacy code. It implies future intent to deprecate the code

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is legacy assumes 2 states, Legacy and Current and does not account for a 3rd state to exist at the same time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something I don't remember to think about until you raise it in reviews, but I'm trying to internalize it into my normal review process :)

I agree it would have been better not to use that name, but in this case I think it'll end up okay, because this was a big change to an API surface that we very explicitly don't want a lot of churn to, and hasn't been fundamentally changed like this in the entire life of the plugin. It's a very different case than, e.g., Android older API version codepaths, where this has come up before, where we can easily get new ones every year.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep I did not view it as a blocker which was why it came paired with an approval. It was just the dismissal that "I think legacy is pretty fitting, as it is now legacy code." that I wanted to expand upon since that misses my entire reason for commenting on the name.

I should have linked to the style guide. https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-newold-modifiers-in-code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code, and the names specifically, can also change any time without breaking anything, as this is just the native platform implementation. If there does end up being another massive overhaul before it's deprecated, we can just change it to something else at that time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's always LegacyLegacy ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

yes there is hahaha 😭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was just the dismissal that "I think legacy is pretty fitting, as it is now legacy code." that I wanted to expand upon since that misses my entire reason for commenting on the name.

Totally fair, I was missing the expanded context so I appreciate the comment :)

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.util.Map;
import java.util.Set;

/** DeprecatedSharedPreferencesPlugin */
public class DeprecatedSharedPreferencesPlugin implements FlutterPlugin, SharedPreferencesApi {
/** LegacySharedPreferencesPlugin */
public class LegacySharedPreferencesPlugin implements FlutterPlugin, SharedPreferencesApi {
private static final String TAG = "SharedPreferencesPlugin";
private static final String SHARED_PREFERENCES_NAME = "FlutterSharedPreferences";
private static final String LIST_IDENTIFIER = "VGhpcyBpcyB0aGUgcHJlZml4IGZvciBhIGxpc3Qu";
Expand All @@ -38,12 +38,12 @@ public class DeprecatedSharedPreferencesPlugin implements FlutterPlugin, SharedP
private SharedPreferences preferences;
private SharedPreferencesListEncoder listEncoder;

public DeprecatedSharedPreferencesPlugin() {
public LegacySharedPreferencesPlugin() {
this(new ListEncoder());
}

@VisibleForTesting
DeprecatedSharedPreferencesPlugin(@NonNull SharedPreferencesListEncoder listEncoder) {
LegacySharedPreferencesPlugin(@NonNull SharedPreferencesListEncoder listEncoder) {
this.listEncoder = listEncoder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.mockito.Mock;
import org.mockito.Mockito;

public class DeprecatedSharedPreferencesTest {
public class LegacySharedPreferencesTest {

DeprecatedSharedPreferencesPlugin plugin;
LegacySharedPreferencesPlugin plugin;

@Mock BinaryMessenger mockMessenger;
@Mock FlutterPlugin.FlutterPluginBinding flutterPluginBinding;
Expand All @@ -44,7 +44,7 @@ public void before() {
Mockito.when(flutterPluginBinding.getApplicationContext()).thenReturn(context);
Mockito.when(context.getSharedPreferences(anyString(), anyInt())).thenReturn(sharedPrefs);

plugin = new DeprecatedSharedPreferencesPlugin(new ListEncoder());
plugin = new LegacySharedPreferencesPlugin(new ListEncoder());
plugin.onAttachedToEngine(flutterPluginBinding);
}

Expand Down