NaturalSort.Extension icon indicating copy to clipboard operation
NaturalSort.Extension copied to clipboard

Questioning the namespace design

Open maettu-this opened this issue 11 months ago • 3 comments

All code is placed into NaturalSort.Extension. However, only NaturalSortExtension are "Extension" methods. Shouldn't the code better be structured as follows?

namespace NaturalSort class NaturalSortComparer namespace NaturalSort.Extension class NaturalSortExtension or NaturalSortExtensionMethods

Rationale of this proposal:

  • With the current design, all being placed in a single namespace, a using NaturalSort.Extension; will always make both Comparer and Extension visible.
  • WIth the proposed design, the user can selectively make Comparer and/or Extension visible, same as e.g. the System.LINQ namespace that makes extension methods for e.g. System.Collections visible.

maettu-this avatar Feb 19 '25 20:02 maettu-this

Yes, I guess that would make more sense.

But then again NaturalSort.Extension is the name of the NuGet package (which I guess is also not 100% perfect). This way it's the same namespace as the NuGet package name, so at least it's somehow aligned here.

I'm afraid to change the NuGet package name now that it has 1.5M downloads...

tompazourek avatar Feb 20 '25 15:02 tompazourek

Maybe we can think about the "extension" meaning not just an extension method, but an extension to the BCL.

Like how all the Microsoft.Extensions.* packages aren't just extension methods.

tompazourek avatar Feb 20 '25 15:02 tompazourek

I see. Didn't know about the Microsoft.Extensions. Just noticed that all other "extension" libraries I use aren't named like that.

Maybe the idea behind can be commented in code. I fully understand you don't want to change something that basic anymore.

maettu-this avatar Feb 21 '25 15:02 maettu-this