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
Prefixes vs suffixes in class naming #176
Comments
from private discussion with @asiekierka the other day:
|
I would argue that search in most modern Java IDEs would be fuzzy enough that regardless of ordering of BlockBed/BedBlock the result would show. |
I think Mojang uses either suffixes (BedBlock) or just names (Bed). [snip!] Those classes are, probably, in same package and are named like:
|
Another example, which also shows Mojang names doesn't have [snip!] |
This is true if everything gets mapped into one large "sink" package (e.g. |
While your efforts are commendable, please do not post MCP content in here. Please use Enigma mappings or Tiny mappings from pomf to demonstrate your point next time, or hint at it without posting names directly. The research is appreciated, however! We were already aware of Mojang not using I-prefixes thanks to Brigadier, but the other hint is pretty interesting. I was planning on looking at the alphabetical ordering myself at some point, however it also needs not be assumed that Minecraft's "internal names" are perfect or fitting for a more modded development environment. |
I personally like having the prefixes, because that means all the items get grouped together, all the biomes get grouped together, etc. Of course, the counter-argument is that suffixes make everything that has something in common get grouped together, like IronIngot, IronSword, IronBlock, IronChestplate, etc. |
@Boundarybreaker Actually, it's that they're in packages anyway. So, in .block, things are already grouped together. It doesn't matter if it's BlockBed and BlockChest or BedBlock and ChestBlock. |
Ah, yeah. That is a good point. I was more thinking from mod-dev side. I'm fine with suffixes, then. |
Personally in all my code I use prefixes instead of suffixes on my class names. There's some exceptions to that rule for pretty much every situation that comes up I end up going for prefixes. I find it works better when searching for a type of object in my IDE, and honestly just looks better to me. A lot of this is opinion based and if you look at other mods source code on github it's pretty clear that most people are happy with class names using a prefix instead of a suffix. |
I think all mods use prefixing because they are using MCP names and MCP names mostly use prefixing because long time ago all minecraft was deobfuscated into single
From C# Design Guidelines I think using prefixes kind-of locks you in that scheme and doesn't allow for any "judgment". But maybe it's not really needed for wide inheritance hierarchies, like that of |
I've just thought, look at JEI implementations. There's no prefixing precedents in api and so all across the modding commmunity JEI-support classes are Machine+Category/Wrapper/etc. |
MCP did not have the suffix move because of large-scale dependencies from existing mods. This is not the case in fabric. |
Yes. I'm already keen on doing it, it's just a decent amount of effort to sit down and do it. |
I've just thought: prefixes != backwards spelling, also they come in different flavors Examples from MCP: [snip!] I think you'll agree that inconsistency in naming is bad, names like [snip!] are terrible. I'm probably too late with this... |
Please stop posting MCP examples on pomf communication channels, or I will be forced to block you from the GitHub repository. |
"BiomeDesert" vs "DesertBiome", etc. Or "ComponentTranslatable" vs "TranslatableComponent".
The former has advantages when sorting names in an editor and is my personal preference; the latter is more common in Java development and is preferred by most other people.
The text was updated successfully, but these errors were encountered: