Skip to content

Inconsistent naming for singleton properties (Shared|Default|Instance) #3493

Open

Description

Describe the issue

We have a bunch of singleton properties in the toolkit, but with inconsistent naming. I'm wondering whether it wouldn't make sense to have them all converge on a single term, to make them more intuitive for developers. Changing the name would obviously be a breaking change, so this seems like a good moment to consider this with 7.0 around the corner.

A few examples:

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/a7f897616ba9b7d4ac26934f3439335be7830eb4/Microsoft.Toolkit.Uwp/Helpers/SystemInformation.cs#L40

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/32656db1cdd4ddc25e3a88c297ce4062fe64d2ad/Microsoft.Toolkit.Mvvm/Messaging/StrongReferenceMessenger.cs#L89

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/1739fb8195f2479772747328c2a755df6b987761/Microsoft.Toolkit.HighPerformance/Buffers/StringPool.cs#L166

For reference, here's the singleton instance ArrayPool<T>.Shared from CoreCLR: link.

Expected behavior

Given that in all these cases we're dealing with singleton instances that are also thread-safe, hence having a similar role (with the given differences due to them being in different types), I figure maybe a single name should be used in all cases. To be consistent with CoreCLR too and since all instances do share the thread-safety feature too, I'm thinking probably Shared?

StringPool will definitely need to use Shared to be consistent with ArrayPool<T>.Shared, so the other two would need to be changed in that case. Otherwise, we could just leave the names different in those cases, looking for feedbacks on this 😄

Additional notes

A decision on this should be made before the 7.0 release is published (including #3230), and I was thinking maybe it'd be best to decide on this before #3424 is merged so that the updated name would already be included in the next preview package for the MVVM Toolkit, so that devs would have more time to get used to that?

Note regarding switching to Shared for messenger, that'd be different from Default being used in MvvmLight, but not necessarily an issue since devs moving from there would already have to make some code changes anyway.

cc. @michael-hawker @jamesmcroft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions