Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper vs Util vs Utils #1108

Open
Earthcomputer opened this issue Feb 9, 2020 · 24 comments
Open

Helper vs Util vs Utils #1108

Earthcomputer opened this issue Feb 9, 2020 · 24 comments

Comments

@Earthcomputer
Copy link
Contributor

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.

@Prospector
Copy link
Contributor

Prospector commented Feb 9, 2020

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

@Prospector
Copy link
Contributor

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

@liach
Copy link
Contributor

liach commented Feb 9, 2020

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.

@Earthcomputer
Copy link
Contributor Author

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

@liach
Copy link
Contributor

liach commented Feb 9, 2020

I've argued for Maths long ago, given it is a valid abbreviation for Mathematics. #249 (comment)

@Prospector
Copy link
Contributor

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

@liach
Copy link
Contributor

liach commented Feb 9, 2020

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

@liach
Copy link
Contributor

liach commented Feb 9, 2020

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

@Earthcomputer
Copy link
Contributor Author

Earthcomputer commented Feb 9, 2020

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.

@Earthcomputer
Copy link
Contributor Author

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.

@Juuxel
Copy link
Member

Juuxel commented Feb 22, 2020

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

No?

votes

@Earthcomputer
Copy link
Contributor Author

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

@Sollace
Copy link
Contributor

Sollace commented Feb 22, 2020

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.

@Sollace
Copy link
Contributor

Sollace commented Feb 22, 2020

PiglinHelper -> Piglins

@Sollace
Copy link
Contributor

Sollace commented Feb 22, 2020

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

I thought Maths was an exclusively American term?

@grondag
Copy link
Contributor

grondag commented Feb 22, 2020

MathHelper -> Mathinator

@Sollace
Copy link
Contributor

Sollace commented Feb 22, 2020

Maps? I

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

@Earthcomputer
Copy link
Contributor Author

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.

@Earthcomputer
Copy link
Contributor Author

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.

@Earthcomputer
Copy link
Contributor Author

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.

@Sollace
Copy link
Contributor

Sollace commented Feb 22, 2020

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

@Earthcomputer
Copy link
Contributor Author

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.

@jaskarth
Copy link
Contributor

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

@Runemoro
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants