-
Notifications
You must be signed in to change notification settings - Fork 267
TestTerminalPosition, TestTerminalRectangle & TestTerminalSize and changes to those classes #601
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
base: master
Are you sure you want to change the base?
Conversation
LANTERNA-fix split panel cleanup TerminalPosition, reduce object memo…
LANTERNA-using TerminalSize.of() rather than new TerminalSize()
LANTERNA remove unused getDimension() from TerminalSize
…nalSize TerminalRectangle
LANTERNA TestTerminalRectangle
|
Let me know of anything I need to address for this merge request. |
|
I think, this PR is too much at once. Try to split it up into separate topics that can be individually checked and judged. Removing methods is not to be taken lightly (unless it were about private methods.) PS: I do not have any say here - I'm only just a "contributor". Edit: I removed a comment about multiply/divide when I saw these methods already existed before and that only an overload was added. That's fine (imho). |
|
One more comment about the changes in TerminalSize: 1.) making the fields public is a "no go" - it contradicts "immutability". 2.) I like the static method "of", but its current implementation does 4 comparisons in the non-trivial cases, and up to 6 comparisons in the semi-trivial cases (with only one component in {0,1}). actually, I think that constants for 0x0 and 1x1 would be enough... The use cases for 1x0 and 0x1 are pretty low imho, and having fewer branches in "of" is probably a better investment than 1,0 and 0,1 instances... In that sense, my suggestion for the initial part of "of()" would be: |
|
I'm overall ok with this typo of change (on master, since it breaks backward compatibility); just not sure what prompted you to start refactoring these? Could you maybe squash the commits as well? |
Core changed classes:
Primary change:
removed public static fields from TerminalRectangle, seems methods like x() y() width() height() are almost as succinct as fields of those names, but have some benefits like smaller memory use and potentially clears the path and opens up options with interfaces and default methods
added x(), y(), width() and height() methods to TerminalPosition, TerminalSize and TerminalRectangle, this is because they are they are succinct
using static TerminalSize.of() TerminalPosition.of() rather than constructor, this allows for further memory optimizations like reusing TerminalPosition(0,0) TerminalSize(80,40) etc.
Reason for the different parameters on the methods is to provide ease of use.
The methods like withRelativeRows(), withRelativeColumns() are left in, but they are synonymous with plus() or minus().
Also, they now all have the logic which can return the same instance if the resulting TerminalSize or TerminalPosition were to have the same columns & rows.
Added convenience equals(int, int) method:
Possibly: