Yarn: MinecraftClient.openScreen -> setScreen

Created on 21 Jul 2020  路  10Comments  路  Source: FabricMC/yarn

It first closes the current screen. openScreen makes it sound as if the previous screen stays open, and setScreen(null) makes more sense than openScreen(null).

refactor

Most helpful comment

setScreen makes it sound like a simple setter

The whole point of a setter rather than just a field is having extra logic run when the field is set (whether that extra logic is already present, or you want to have the possibility of adding it in the future without breaking code that's setting the field).

All 10 comments

Yup, makes perfect sense to me. There's only ever one of them.

yeah it swaps screen as well, so setScreen is indeed better

Not a fan of this change, really. setScreen makes it sound like a simple setter, but if the consensus is to go for it... okay

Or present/display/show?

If we go for liach's suggestions, at that point it just feels like we are changing the name for the sake of changing the names

Lol otherwise you need to derive one that pleases shartte

setScreen makes it sound like a simple setter

The whole point of a setter rather than just a field is having extra logic run when the field is set (whether that extra logic is already present, or you want to have the possibility of adding it in the future without breaking code that's setting the field).

@liach Nah, no need to please me. I don't think this is _particularly_ important, and think the current name is fine, but renaming it setScreen is not the end of the world :-D

Another suggestion: switchScreen

switchScreen(null) still makes perfect sense, and it doesn't have the issue of looking like a setter or a reversible operation.

If we go for liach's suggestions, at that point it just feels like we are changing the name for the sake of changing the names

I thought that was the issue here? I find openScreen very confusing, I spend a good five minutes looking for a closeScreen, lastScreen, or popScreen. Objects that have an open should be expected to have a close at the very least.

present/display/show could potentially have the same issue, although their inverses aren't nearly as universal (destroy, conceal, hide).

setScreen is just fine, though, since setters can have more code than just field = param. Yarn already calls many longer setters setX even though they do more than just set a field's value.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Runemoro picture Runemoro  路  4Comments

quat1024 picture quat1024  路  6Comments

asiekierka picture asiekierka  路  3Comments

Draylar picture Draylar  路  6Comments

asiekierka picture asiekierka  路  4Comments