Earlier quoted context omitted.
int n = 42; int acc = 0; Fixed Edit: Install http://wbond.net/sublime_packages/alignment and add this key binding `{ "keys": ["ctrl+shift+a"], "command": "alignment" }`.
That's actually right against the style guideline of many projects which tell you explicitly not to do this but to simply put the = sign and value right after the variable name and be done with it. Lining them up serves no purpose and does not in fact make the code easier to read.
How to name things in programming
31–40 of 177 posts
Re: How to name things in programming
#32Nice write-up. But there's not a single slide about usability and how it affects naming. If your library exposes 'getCurrentRuntimeContext' which is going to be used in every other line of user's code, name it 'ctx'. It's ambiguous, but it saves the user 3 seconds per 2 lines of code. As for the readability, when the reader encounteres 'ctx' for the third time (at line 6 of the source file) they will already know wha…
I'm not so sure that is good advice, and I come from C programming so we love to do that. With autocompletion in most code editors saving the user typing time is not a valid argument anymore, and I would rather prefer comprehensible if slightly more verbose code than accronyms everywhere. What is obviously ctx -> getCurrentRuntimeContext for you is completely foreign to the next guy. And sometimes you don't spend a l…
That would suck in a big way.
Re: How to name things in programming
#33Earlier quoted context omitted.
int n = 42; int acc = 0; Fixed Edit: Install http://wbond.net/sublime_packages/alignment and add this key binding `{ "keys": ["ctrl+shift+a"], "command": "alignment" }`.
Which, when you add a third variable "stuff", will require you to go back and add a space for both n and acc, pollutting both the diffs themselves (making reviews harder) and the git-blame (making pinpointing bugs harder).
git diff -wRe: How to name things in programming
#34I miss a few things though.
1. Short functions can use abbrevs; because I can keep track of them.
2. "text_correction_by_editor" might convey a lot more info then "edit"; especially in code where "edit" (and derivative) are heavily overloaded. For instance I can imagine "text_correction_by_user" also exists, or "text_reload_by_editor".
3. Then the Java'isms. E.g. AbstractWhateverSomethingManager. This is more part of the language, paradigm (OO w/ big love for design patterns) and type of money used to pay for development (enterprise money). Its verbose, deterministic and very "correct". Once you are used to the jargon you quickly know what they do, as they explicitly encode one of more patterns in their name.
Re: How to name things in programming
#35Re: How to name things in programming
#36Earlier quoted context omitted.
That's actually right against the style guideline of many projects which tell you explicitly not to do this but to simply put the = sign and value right after the variable name and be done with it. Lining them up serves no purpose and does not in fact make the code easier to read.
To be honest it actually makes code cleaner and therefore easier to read. It's like design have you heard about grid? this is the same thing. Your eyes have to flow the lines. If not everything seems a mess.
Whitespace edits are the code equivalence of wikipedia formatting changes to increase the number of articles you've worked on without actually contributing anything.
Also, if you think that is easier to read you are actually setting yourself up by being deceived by formatting because you'll be skipping bits based on assuming you know what they say. Those are hard lessons to learn but the best way to understand a new piece of code that you're reading is not to read it like a book but like a machine, with a pencil and a notepad tracing the values of the variables as you execute the code in your head (or on the paper if it gets complex). You don't need to run the whole program that way, just the sections that you feel are hard to understand.
Re: How to name things in programming
#37Re: How to name things in programming
#38Earlier quoted context omitted.
Which, when you add a third variable "stuff", will require you to go back and add a space for both n and acc, pollutting both the diffs themselves (making reviews harder) and the git-blame (making pinpointing bugs harder).
There is a plugin in sublime text that I just select the lines and hit ctrl+shift+a and alignes everything in one hit.
And yes, I know about git diff -w, but 1. not all tools built around git support it and 2. not everybody uses git.
Re: How to name things in programming
#39I clicked through the first twenty or so slides, but really I find myself disagreeing completely with him. When you write don't use cliches but the meaning of AbstractConfigProxyFactory is clear and convey more information than anything else.
Two cases where you might want different factory classes(and hence need a common interface or base) are a factory for 'production' code and a factory that only generates mock objects for unit tests.
Having spent 5 minutes trying to understand what this class might do, I disagree with your claim that the name is clear.
Re: How to name things in programming
#40Earlier quoted context omitted.
That's actually right against the style guideline of many projects which tell you explicitly not to do this but to simply put the = sign and value right after the variable name and be done with it. Lining them up serves no purpose and does not in fact make the code easier to read.
To be honest it actually makes code cleaner and therefore easier to read. It's like design have you heard about grid? this is the same thing. Your eyes have to flow the lines. If not everything seems a mess.
But ideally this is something that should be decided by each developer's personal editor config, like tab widths for indentation.