|
That's the trouble. You end up with 7,000 private instances of a, b, and c.
Better is to use meaningful names that don't all start with the same characters (in this case "usableHeight"), and let intellisense do its magic.
nowUsableHeight and newUsableHeight aren't such a pain, but are clear enough.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
The problem isn't the length of the variable names. (Even though they might be some times)
The problem is that the original author didn't think all the way, but even worse, that everyone else is just copy'n'pasting.
Take a look at your refactored code with the original variable names:
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious)
{
frameLayoutParams.Height = usableHeightNow;
It's not that bad anymore is it?
|
|
|
|
|
or... if the Height is a field or a property without side effects in the setter:
frameLayoutParams.Height = computeUsableHeight();
|
|
|
|
|
I thought so as well, but if you follow the link in the OP you'll notice there's more code inside the conditional.
|
|
|
|
|
You are right Jörgen but even worse, that everyone else is just copy'n'pasting.
... such stuff as dreams are made on
|
|
|
|
|
the old "but someone said you should use meaningful variable names" and c&p-coding without getting a grip.
I would rather tend to rename a back to usableHeightNow ... for readability
(yes|no|maybe)*
"Fortunately, we don't need details - because we can't solve it for you." - OriginalGriff
|
|
|
|
|
I agree.
usableHeightNow and usableHeightPrevious don't even meet the requirements of meaningful naming.
They should be currentComputedValueOfUsableHeight and usableHeightExtantBeforeTheCurrentValueWasComputed
[edit] What a time to typo "extant"! Open a ticket; the bloody code won't compile! [/edit]
I wanna be a eunuchs developer! Pass me a bread knife!
modified 1-Mar-17 2:52am.
|
|
|
|
|
I fundamentally disagree.
In the age before the IDE and Intellisense this argument held some water, since descriptive variable names translated directly into writing time. These days I rarely need to type more than three characters and I've locked into the variable that I need.
Long variable names provide description and context, and lead to self-documenting code: that Utopian dream where source code can be quickly understood without being riddled with // or /**/.
The other point is that source code is for people. In the future, that set of people may include you or it may not, but the code will need to be pulled out, brushed off, and modified at some point. A terse variable name may make perfect sense to you, but the next guy is not you and it may or may not to him. I guarantee that a nice, descriptive name will, though.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Wholeheartedly agree!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Long and meaningful variable names are useful in a long-term, global context. In this case, those longer names are obscuring their actual use in a local context.
If you have a complicated calculation that references those names, copy the incoming values to shorter names for purposes of performing the calculation, thereby making it more readable.
Software Zen: delete this;
|
|
|
|
|
This is an intriguing concept. But, other than practicing your bash shell commands without a VM or dual boot, what are some practical uses for it? Can you set up a Linux development environment, run a LAMP or LARP* stack on it?
I'm curious to know what uses CP'ers have found.
*Linux Apache Ruby PostgreSQL.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
It may work better for some games than Wine
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hmm, install bash on Windows, so you can run Wine, so you can run Windows games.
Makes perfect sense.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
It gives you a true 8-bit experience.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Leisure Suit Larry will rise again!
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
Hmm. You're actually turning my head in favour of it!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
It is not a concept, it is for real. And yes you can do LAMP on it or whatever language you fancy, as long as it runs on Ubuntu. Personally I still goes to my VBox Ubuntu most of the time though.
|
|
|
|
|
Oh, I know it's real.
Curious, though, why go back to the VM? What can you do there that you can't do with U on Wen?
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
TNCaver wrote: What can you do there that you can't do with U on Wen? Microsoft didn't implement thunks for all the system calls, so there's some things that just won't run under it but will run under a VM running on top of WinX.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Ubuntu is free and you definitely get what you pay for. It has so many bugs and is not user friendly at all. It's worth paying for Windows. I won't take the cheap route again. Ubuntu sucks!
Wait..., that's not what you meant by bash Ubuntu?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Considerably more power than cmd, less user acceptance issues than PowerShell.
What's not to love?
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Yes. I guess MS have been jealous of the superior commands available in bash that don't exist in MS Dos.
We're philosophical about power outages here. A.C. come, A.C. go.
|
|
|
|
|
Absolutely. Command chaining is a very powerful feature that cmd has sorely lacked. If for that alone, it's worth it.
It also doesn't hurt to have a common command interface for each box in the server farm.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Nathan Minier wrote: Considerably more power than cmd, less user acceptance issues than PowerShell.
You must not read Slashdot.
When MS announced Bash for Windows 10, the resulting discussions were all about how this does nothing to sway any of them back to MS.
Going at it the other way around, when MS announced PowerShell for Linux, the resulting discussions were all about how nobody in their right minds would pollute their pristine Linux systems with MS garbage.
"Less user acceptance issues", my @$$. They just can't win. The attitude in the community makes me want to ignore Linux more than any technical issue or learning curve.
|
|
|
|
|
dandy72 wrote: You must not read Slashdot.
No, that sounds like horribly kinky fan-fiction featuring Dot from Animaniacs, though.
I don't think anyone cares about Linux fanbois, not even Linux fanbois. I was actually talking about Windows user acceptance, as in an enterprise environment I've seen a lot of (IT) people that are so intimidated by PowerShell that they won't use it. They will, however, use bash, since they've had to learn how to when administering appliances.
Maybe the issue here is that when I say "User", I'm meaning anything from baseline User to SysAdmin. To me it just means !Developer.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|