thomasgalliker / ValueConverters.NET

A collection of commonly used IValueConverters for .NET applications
MIT License
148 stars 25 forks source link

Suggestion to rename NullToBoolConverter and IsEmptyConverter #22

Closed sa-he closed 2 years ago

sa-he commented 4 years ago

NullToBoolConverter -> ObjectIsNullConverter IsEmptyConverter -> EnumerableIsEmptyConverter

thomasgalliker commented 4 years ago

I would not rename this converter as I‘ve seen this name in many projects I was consulting for. We could create another class with the name you proposed which inherits from NullToBooleanConverter. (Not really a nice solution, I know).

On the other hand, you have to define x:Keys for each converter anyways. So, what if you just use x:Key=„ObjectIsNullConverter“ in app.xaml?

thomasgalliker commented 4 years ago

Or do you want to split the converter into two? Could give a slight improvement in performance. We could sill leave the old converter and mark it as obsolete.

sa-he commented 4 years ago

Other projects use these names? To me, this is even more reason to rename. It is only going to be a conflict if other projects use the same namespace (which is unlikely). In my opinion good names tell a consuming developer what the converter is doing. For these two I had to look at the source code in order to understand them.

No, I do not suggest to split a converter.

I just went through the list again and add to the list of rename suggestions these:

DateTimeConverter -> DateTimeToStringConverter
VisibilityInverter -> InvertVisibilityConverter  // This one is just to meet the unspoken convention that normally they end with "Converter"
thomasgalliker commented 4 years ago

True that. Check github for occurances of converter names:

I think it is a matter of taste too.

sa-he commented 4 years ago

Yes it is. Feel free to decide however you prefere.

thomasgalliker commented 4 years ago

I know what you must be thinking now: "Why should I name my stuff as wrong as 480 others did" 😄 But the other 480 will be frustrated if their nulltoboolconverter isn't there anymore. I'll ask some more people of what they think.

martin-braun commented 2 years ago

The problem with renaming things is that you introduce breaking changes. I'm a fan of refactoring, but I'm not sure if this is a good idea on such a project.

thomasgalliker commented 2 years ago

True. I will not rename converters as there are many different opinions on names. I prefere the way of inheriting existing converters innorder to create alias class names. Hope that‘s fine.