Inconsistent naming for singleton properties (Shared|Default|Instance) #3493
Comments
|
Hello Sergio0694, thank you for opening an issue with us! I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback |
|
I see the argument for all the current names, they're all slightly different cases. I think I mean I see developers grabbing the instance of So, I'm not sure if I see this as a big problem if we want to keep them separate. It also helps for the messengers to not lead developers to think they should be going to go grab the messenger instance and start using it, eh? @azchohfi thoughts? |
|
Yeah that's a fair point about I was mostly thinking about the |
|
If we change anything, we should deprecate, instruct with a clear warning message, and then delete in a future version. Lets not directly remove any property which would cause a big breaking change and frustration to devs. |
Ah, naming being the most difficult problem in software engineering strikes back If we don't want to deprecate/break things here (which is a good point I can agree with!), I guess then the remaining question for now would mostly just be about what to use for |
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:
WindowsCommunityToolkit/Microsoft.Toolkit.Uwp/Helpers/SystemInformation.cs
Line 40 in a7f8976
WindowsCommunityToolkit/Microsoft.Toolkit.Mvvm/Messaging/StrongReferenceMessenger.cs
Line 89 in 32656db
WindowsCommunityToolkit/Microsoft.Toolkit.HighPerformance/Buffers/StringPool.cs
Line 166 in 1739fb8
For reference, here's the singleton instance
ArrayPool<T>.Sharedfrom 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?StringPoolwill definitely need to useSharedto be consistent withArrayPool<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 thisAdditional 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
Sharedfor messenger, that'd be different fromDefaultbeing used inMvvmLight, but not necessarily an issue since devs moving from there would already have to make some code changes anyway.cc. @michael-hawker @jamesmcroft
The text was updated successfully, but these errors were encountered: