VM
I can't see whether you will really reduce your memory footprint, but why are you worrying about a few hundred bytes? You would have worried about such memory consumption in 1972, but not today.Vineeth Menon wrote:. . . My intention was to reduce memory footprint as much as possible. . . .
VM
Preconditions.checkState(version.length() < 1);
This function returns boolean value if the XCUITest needs to be used.
Campbell Ritchie wrote:but why are you worrying about a few hundred bytes?
Thou shalt not try me. Mom 24:7
That's a pleasureVineeth Menon wrote:Thanks to both of the Marshals . . . .
In which case, I think you have introduced an error when you changed it. That older code might work correctly if version 12.0 counts as a greater version number than version 11.9999999999999999999. No, on thinking about it a bit more, I decided the older code will give incorrect results, too. The newer code makes me suspect you have been guessing about what you should write rather than thinking logically about it. You can guess 1,000,000× and there is good chance that one of the guesses will be correct. You simply have to find it. Or you can think logically about what you are doing and get it right first time. Before you do that, write down the specification for version numbers which you are seeking. Also what happens if you pass version 9.3?This is how I originally wrote the code. . . .
Liutauras Vilda wrote:2.1 method name checkState doesn't give a sense to a user what happens after checking state.
1. Method name isXcui() is poor.
1.1 You wrote javadoc for it, and javadoc has better explanation which could be reflected in method name. i.e.: mustBeXcuiTested() or something, what explains right away what is all about.
1.2 If method throws an exception, there is a notation in javadoc for that @throws.
This line is poor in two ways:
2.1 method name checkState doesn't give a sense to a user what happens after checking state.
2.2 You are checking if version length is less than 1. Technically length shorter than 1 can be only 0. So why you don't check version.length == 0 or version.isEmpty() ?
3. Why the base version is hardcoded in the method? What would happen when base version would change? You'd create new isXcui() variant? Or you would change the method?
Because like me, he learned via Z80 assembler on a TRS-80 where you had 64k total memory, 16k used by the display.
Old habits die hard, I still spend more time than I should trying to save a few bytes here and there. It's not lost on me my code now runs on a laptop with 6 gigs of memory backed by a petabyte of swap space and I want to store my small numbers in 8 bits instead of 32.......
That older code might work correctly if version 12.0 counts as a greater version number than version 11.9999999999999999999
If I pass 9.3 it will return false. The Business Logic also dictates that anything below 9.3 and 9.3 should not use XCUITest.Also what happens if you pass version 9.3?
VM
Liutauras Vilda wrote:
So it is Google Guava library code. However, I am still thinking the same. What a weird method name. Method requires “true”, otherwise exception is thrown, while the method says checkState. If you ask me to check temperature, most likely I would tell you what the temperature is.
Why not checkStateIsTrue, better probably ensureStateIsTrue, verifyStateIsTrue, requireStateTrue, why “state” at all, requireTrue, ensureIsTrue.
VM
Vineeth Menon wrote:
Vineeth Menon wrote:
VM
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |