|
CHill60 wrote: b) used inconsistent indenting
The first thing I'd do in that case is to autoformat the indenting into something approaching sanity, even if I had no intention of making a 500 whitespace change commit just to make everything else easier.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
CHill60 wrote: a) put in braces for no apparent reason
Hmmm, be careful with removing braces in the middle of the function. Unless you know why the other engineer put them there. They can be used to enforce variable scope. You can actually use them to reduce the memory usage in a thread.
Best Wishes,
-David Delaune
modified 15-Feb-18 1:18am.
|
|
|
|
|
Trust me ... this guy wasn't that clever
As for variable scope ... most of his stuff was global
The whole thing was re-engineered - was clearer to read, faster to operate and used far less memory (and "leaked" none) by the time we finished.
|
|
|
|
|
|
I prefer:
if (condition)
statement; //short and simple only, no multi-line lambdas, nested calls, etc.
if (condition)
{
statement; //everything else
}
For truly simple, short statements it just looks cleaner in my opinion.
EDIT: Also I don't mix the styles like
if (condition)
statement;
else
{
statement;
statement;
}
If a brace is needed for one I make the rest braces as well.
modified 13-Feb-18 1:47am.
|
|
|
|
|
Most of the time, if in Visual Studio, I use the if code snippet that adds the braces anyway. I generally prefer them but I don't usually alter existing code that doesn't have them.
Otherwise, for one-line statements I might write
if (condition) statement;
Kevin
|
|
|
|
|
I find that having:
if (condition)
{
statement;
}
makes it easier for debugging, because the code path is much more obvious, and I can search it quicker.
|
|
|
|
|
So I always use braces
I didn't care until I found some weird behaving code.
if (something)
statement;
statement;
statement; Yeah...
|
|
|
|
|
Exactly!
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
As the solo dev here, I get to do whatever I want. For single statement blocks, I almost always leave out the curly braces.
Over the years, I've really come to despise braces and semi-colons altogether and nowadays opt for VB on new projects.
"Go forth into the source" - Neal Morse
|
|
|
|
|
kmoorevs wrote: As the solo dev here And there's the rub.
/ravi
|
|
|
|
|
A solo developer should always write code with the next solo developer in mind. He might be very large and highly psychotic - a few diligent keystrokes today could save several indiscriminate axe-strokes tomorrow.
98.4% of statistics are made up on the spot.
|
|
|
|
|
PeejayAdams wrote: highly psychotic
Psychotic people are statistically less violent than the general population. Just sayin.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard Andrew x64 wrote: Psychotic people are statistically less violent than the general population.
Too many violent people who have yet to be captured and categorized as psychotic then. Unless those the majority of psychotics are just eating mushrooms and licking frogs.
|
|
|
|
|
Bassam Abdul-Baki wrote: Too many violent people who have yet to be captured and categorized as psychotic then.
You must be confusing psychopathic people with psychotic people. It's the psychopaths that can be violent, not the psychotics.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
just my personal opinion but the braces (not brackets) should be used and properly formatted.
if (true == value) {
foo = value;
}
I am also a proponent of constant values on the left side of the condition. This comes from my early days of C/C++ development and wanting the compiler to catch code mistakes like a missing '=' sign.
|
|
|
|
|
Braces should be required but I don't like the K&R style. But as the survey said: "one war at a time!"
98.4% of statistics are made up on the spot.
|
|
|
|
|
If you're doing it like this:
if (whatever) {
DoStuff();
DoMoreStuff();
}
if (something) {
DoAThing();
}
you need them even for one liners to preseve visbility and because in javascript the auto semicolon inserter will blow up in your face if you don't.
OTOH if you put the opening brace on its own line
if (whatever)
{
DoStuff();
DoMoreStuff();
}
if (something)
DoAThing();
the normal increased visibility of the opening one makes accidentally assuming a closing one too a lot harder and IMO unneeded.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
|
It's just how I was raised.
|
|
|
|
|
You're right. Updated.
cheers
Chris Maunder
|
|
|
|
|
So that intent is clear. I saw code once that did not have curly braces but the lines below were also indented. So annoying because it looked like all the lines were part of the statement.
Don't be so lazy. Just always use them.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
my bacon crispy. Usually 3 slices per burger does the trick. Mayo on one roll, spicy brown mustard on the other (or dijon). Lettuce (Iceburg, shredded), swiss cheese or American if melted. White onion chopped. No tomatoes for me, thanks.
Salt and pepper to taste, on the medium rare burger (70% fat on the burger meat) Lean vs Fat: What's The Perfect Ratio For Burgers? – Schweid & Sons – The Very Best Burger[^]
Buns lightly toasted with butter (real not fake).
-- rants are the vehicle of the lazy and uninspired - JSOP 2/2018
|
|
|
|
|
Well there goes my diet.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I know you are a healthy eater. But, every now an then I have a hankering for some "bad" food, and burgers are at the top of that list.
Doc has me on a low to no red meat diet, so I don't eat burgers as often (or steaks for that matter), but I think that might change for lunch today.
-- rants are the vehicle of the lazy and uninspired - JSOP 2/2018
|
|
|
|