Yarn: Helper vs Util vs Utils

Created on 9 Feb 2020  ·  24Comments  ·  Source: FabricMC/yarn

There are 12 classes suffixed with Helper:

net/minecraft/server/rcon/BufferHelper
net/minecraft/server/rcon/DataStreamHelper
net/minecraft/client/gui/DrawableHelper
net/minecraft/client/util/math/Rotation3Helper
net/minecraft/client/util/DefaultSkinHelper
net/minecraft/client/texture/MipmapHelper
net/minecraft/nbt/NbtHelper
net/minecraft/block/RailPlacementHelper
net/minecraft/world/SpawnHelper
net/minecraft/util/JsonHelper
net/minecraft/util/math/MathHelper
net/minecraft/enchantment/EnchantmentHelper

There are 17 classes suffixed with Util:

net/minecraft/client/sound/AlUtil
net/minecraft/client/util/InputUtil
net/minecraft/client/util/GlfwUtil
net/minecraft/client/util/SmoothUtil
net/minecraft/client/model/ModelUtil
net/minecraft/client/texture/TextureUtil
net/minecraft/util/ChatUtil
net/minecraft/util/MapUtil
net/minecraft/util/FileNameUtil
net/minecraft/util/Util
net/minecraft/entity/ProjectileUtil
net/minecraft/entity/ai/brain/task/LookTargetUtil
net/minecraft/entity/effect/StatusEffectUtil
net/minecraft/entity/DamageUtil
net/minecraft/potion/PotionUtil
net/minecraft/test/StructureTestUtil
net/minecraft/test/TestUtil

There are 5 classes suffixed with Utils:

net/minecraft/client/util/ScreenshotUtils
net/minecraft/client/util/NetworkUtils
net/minecraft/client/util/GlAllocationUtils
net/minecraft/network/NetworkThreadUtils
net/minecraft/network/NetworkEncryptionUtils

We should probably pick a standard and stick to it. I'm personally in favour of Utils, but I would like to hear others' opinion.

discussion

Most helpful comment

I like the singular Util the best. 👍 for Util. 👎 for Helper, 😕 for Utils

All 24 comments

I like the singular Util the best. 👍 for Util. 👎 for Helper, 😕 for Utils

tbh I could go any way, just let's be consistent.

Also if we have verbs we can use -ing (gerund), e.g. Chatting NetworkThreading, or plural nouns, e.g. Projectiles Screenshots over Helper Util etc.

That makes it hard for some things like MathHelper -> Maths?? Or Util -> s??

I've argued for Maths long ago, given it is a valid abbreviation for Mathematics. https://github.com/FabricMC/yarn/issues/249#issuecomment-446102638

Yarn uses American English names, where Maths isn't a valid abbreviation for Mathematics.

In this case where neither gerund nor plural applies, I suggest falling back to Helper suffix. Otherwise prefer ing or s, like Texts

Also DrawableHelper isn't a utility class but a functional interface or abstract class with a lot of convenient instance methods

My issue with liach's proposal with -ing and -s is that it makes it very hard to make anything consistent, completely defeating the purpose of the issue. You could make it so count noun utility classes end in -s, but then you are going to have exceptions: Nbts, RailPlacements, Maps? It would be impossible to make consistent.

We should adopt a standard and stick to it. Looking at the vote, that should be either Helper or Util, but not Utils.

One argument for Util over Helper is that the class Util itself doesn't make sense to be called Helper. I think MathHelper being called MathUtil wouldn't be that bad, it's just that everyone is used to it being called MathHelper. I've worked in projects where the maths utility class has been called MathUtil, and it's been absolutely fine, doesn't make a difference. The name MathUtil wasn't even discussed in the MathHelper renaming issue.

There are more Util classes than Helper classes currently, but that needs to be weighted by how often the classes are actually used, so I'm going to look into that now and report back the results.

It seems that the majority of people are for the Helper suffix. Therefore I propose renaming all current classes ending with Util or Utils (except the class Util itself) to end with Helper. Renames of other classes to end in Helper can be discussed in separate issues.

It seems that the majority of people are for the Helper suffix.

No?

votes

Oh, whoops, I must be blind. Then I propose we rename all classes ending in Helper to instead end with Util.

I propose that suffixes are the work of the devil and that we rename all class ending in a *elperer and *til to not have that suffix.

MathHelper -> Maths.

PiglinHelper -> Piglins

Yarn uses American English names, where Maths isn't a valid abbreviation for Mathematics.

I thought Maths was an exclusively American term?

MathHelper -> Mathinator

Maps? I

Note also that Guava (I think it was Guava?) uses the plural pattern: Maps, Sets, Collections, Streams.

This was my problem with using plurals. Although the names look nice, there are too many exceptions. Either because the word is a mass noun (e.g. "math") and therefore has no plural, or because the plural is already taken by another library (e.g. "map"). It would make it too hard to stay consistent, defeating the point of changing them in the first place.

Names that would be okay in plural form:

  • Buffers
  • DataStreams
  • Drawables
  • DefaultSkins
  • Mipmaps
  • Nbts
  • RailPlacements
  • Spawns
  • Inputs
  • Models
  • Textures
  • FileNames
  • Projectiles
  • LookTargets
  • StructureTests
  • Tests
  • Screeenshots
  • GlAllocations

Names that aren't okay because they're mass nouns or not a noun:

  • Jsons
  • Maths
  • Als
  • Glfws
  • Smooths
  • Damages (the plural has a different meaning)
  • Networks (there is only one network here)
  • NetworkThreads (there is only one network thread)
  • NetworkEncryptions

Names that aren't okay because they're already taken:

  • Enchantments
  • Maps
  • StatusEffects
  • Potions

Names that aren't okay for miscellaneous reasons:

  • Rotation3s (this name requires more thought)
  • Chats (although technically the plural of chat, it doesn't fit well as a utility class for "the chat", assuming that's what it's for. If it's for text components, then "Texts" would be an okay name)
  • Utils (we can't rename this to "s" lol, it's better kept as "Util")

In total, 18/34 names would be okay as a plural, meaning we would have to come up with better names for the other 16. So much for consistency.

I would be okay with using plurals where it does make sense and falling back to a Util suffix where it doesn't make sense. Then at least we have a rule to follow rather than randomly choosing between "Helper" and "Util", which is what we currently do.

@Earthcomputer NetworkThreads works fine, though. It's utilities for working with network threads. Doesn't matter that there's only one of them.

You may disagree with me on one or two of those points but that's not the point, it doesn't change the overall ratio of 18/34 by a lot.

I would argue for either Util or Helper, removing them entirely doesn't make too much sense to me.

By the way, some can't be named Util. For example, DataStreamHelper isn't a util class, it's an object that wraps a data stream.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

copygirl picture copygirl  ·  13Comments

Juuxel picture Juuxel  ·  15Comments

sfPlayer1 picture sfPlayer1  ·  11Comments

Runemoro picture Runemoro  ·  10Comments

Runemoro picture Runemoro  ·  10Comments