Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I might be in the minority, but I think using variables of equal lengths with opposite meanings is an anti-pattern. I like using clearly different words (diff lengths, diff starting characters) that still pair well together. IMO this makes it much easier to scan through code, and much less likely to accidentally use the wrong function/variable somewhere.


> I think using variables of equal lengths with opposite meanings is an anti-pattern.

Perhaps the worst example of this is Kotlin’s var/val. I much prefer var/const.


I get the sentiment, and I'd go further to say that I prefer Rust's `let` vs `let mut`, i.e., the longer & visually noisier option discourages mutability by default, and draws attention to when it is used.


I use a CLI app that is used like this:

`command get/set [long directory]`

Because of that long directory part, I use the command history instead of retyping the whole thing. I probably already lost a cumulative total of hours executing `set` instead of `get` by mistake.


Equal-length variable names help to see differences in the remainder of the line. You are more likely to spot mistakes in code where stuff that should be the same is aligned the same.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: