can we agree that T is a dumb variable name?

I mean I totally know what it means in that instance, but why do people keep writing math stuff like they'd skribble it on paper?

  • 3
    It's tea time
  • 4
    No, T is the perfect name for a generic type variable when you only have one variable type.
  • 2
    100% agree it's dumb, but in a single instance we have been "educated" to tolerate it due to many many brainwashing examples using it.
    Same goes for "i" in a for loop.

    But as soon as there's 2 or more, I always go for meaningful name like Fragment<VIEW, MODEL> and avoid Fragmet<T, V> crap
  • 2
    @LordPeeve same. The linter is set up to warn about identifier names with less than 3 characters, with some exceptions like "in" or "at" that are commonly used for function parameter names (or labels).

    I’ve also put T into the whitelist for generic type parameters but I rarely use it because you can almost always come up with a better name.
    Like List<Element>.
    I use T when the generic type literally means any type. Like for deserialization.
  • 2
    @Oktokolo I completely forgot about that generic thing.

    In the codebase I started working on T is used for an array of transformation matrices
  • 1
    @Lensflare 💯

    I may have been guilty of using T for less than fully basic object type but in my defense I was young and it achieved brevity (e. g. <T : Animal>).

    I'm still being told I'm too picky when I ask teammates to change it in their pull requests 🙄
  • 2
    I use T for generic types because that's also how it's done in all the .NET framework source.

    If there are multiple types then I make it more descriptive.
  • 1
    @electrineer I feel dimmer for even having upvoted this.
Add Comment