WTLHelper icon indicating copy to clipboard operation
WTLHelper copied to clipboard

Why are helpers defined with abstract + final

Open Cytotropist opened this issue 1 year ago • 1 comments

I've noticed almost all helpers in WTLHelper are defined like:

struct SomeHelper abstract final 
{
    static bool StaticMethod();
};

My current understanding is that this behaves just like a namespace right? I mean, we can't really instantiate (abstract) nor derive(final) from these helpers. I'm just curious why was this pattern chosen instead of a namespace? Regardless, I'm enjoying using this since I got started with WTL so thank you

Cytotropist avatar Feb 21 '24 20:02 Cytotropist

"abstract final" means that no instance could be created and no class could be derived. The class just provides a bunch of static helpers. It's similar to putting them in a namespace. However, with a namespace you can use "using namespace foo" to gain access without the namespace name, which you cannot do with a class/struct. That's why I prefer it.

zodiacon avatar Feb 29 '24 12:02 zodiacon