Re: [PIC] Learning C
"Forrest Christian (List Account)" <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <CAKsZx=2VKTeEJQqgEYz_JcWrqL-78qSAOn8dHVLo5oSz6qJGUg@mail.gmail.com> |
As I've heard from more than one compiler developer: "Labels survive about a half of a second into the compilation so there's no reason to be skimpy on their length" I usually do something like: ambientTemperatureSensorRawValue Or: ambientTemperatureSensorCelsiusX10 Note that some C compilers don't support variable names over a certain length so the second one might be a bit long. With modern editors, you rarely have to type the full variable name of an already defined variable. Note that this makes code a lot easier to read: ambientTemperatureSensorCelsiusX10 = ambientTemperatureSensorRawValue / 1234 - 23; On Tue, Nov 19, 2024, 6:49 PM Justin Richards <[email protected]> wrote: > I stressed liberal use of comments, and using > > > variable and function names that make sense. > > > > warning. Rambling ahead > > I seem to spend lots of time dreaming up variable and function names that > are concise. Others seem to do it with ease. > > For example I am regular dealing with temperature. Temp is terrible, > temperature is too verbose and after many iterations I have currently > settled on degC as a variable name. > > I consider I will never be an Ok C programmer until I master this seemingly > trivial activity. > > I also labour over making code easier to read or easier to maintain. Which > sounds like a contradiction. > > An example is the choice of an esp8266 dynamically or statically generating > table elements of a web page. > > Statically means I have to update two or more sections of code to make > changes, where as dynamically requires making changing to only one section. > > The static option is more obvious and readable when later revisited but > onerous to make changes where the dynamic code is quicker, less error > prone but more obfuscated. > > Paralysed by indecision. > > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > https://mailman.mit.edu/mailman/listinfo/piclist >