|
E.g. the Coverity analyzer pinpoints such problem as those you point out. (But you have to do the reformatting yourself)
In any case: If you have a code formatter that enforces code layout according to a complete set of rigid rules, then it doesn't matter if the coder writes the code in the way you indicate - the formatter will fix it.
If the formatter does not enforce a rigid set of rules, or if the rule set is incomplete, then there will always be ways in which the coder could mess up things.
So we are talking about either which rules should a formatter enforce, or which rules should the coders write theuir code by. When I am not under the control of some other coding style, among the rules I follow are
* You never have an indent without a bracing construct (which one is language dependent)
* You never have a bracing construct without an indentation.
* You never have a statement separator (such as a semicolon) anywhere but at the end of a line.
* If the body of a structured statement (such as an if) is a single statement (and need no bracketing) and it fits within a line lenght of 80, they it might be accepted on the same line. Otherwise, and it is moved to the next line, it must be indented and braced (according to the first rule).
Having programmed by these rules for thirty years, it would take me a lot of pain to break them. I would never accept it in code that I am responsible for.
|
|
|
|
|
Another guy that can't write code, yet he feels qualified to tell everybody else how it should be done.
I put that as succinctly as I could.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You make it sound as if "writing code" is dominated by blank lines, possibly with a single brace, and statements of at most 40 char length.
If he "feels qualified to tell everybody else how it should be done", how is that with you? Maybe the difference is that you are qualified to do so?
|
|
|
|
|
Member 7989122 wrote: You make it sound as if "writing code" is dominated by blank lines, possibly with a single brace, and statements of at most 40 char length.
You can put all the comments and blank lines in the code that you want, braces on their own lines, and limit lines to any length you like. The compiler optimizes out anything it can't use, and even optimizes "bloated code" to a point. If you didn't already know that, then maybe you should be writing articles to tell us how to code, as well.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: The compiler optimizes out anything it can't use, and even optimizes "bloated code" to a point. I am certainly not worried about how readable the code is to the compiler. I am worried about the humans. Arguing that "the compiler can handle bloated code, so let me write bloated code" doesn't fit well with my ideas about good coding practice.
I actually agree a lot with the author of the referenced article. I have one major point of disagreement: A code indent is triggered by a brace, or similar construct in other languages (e.g. begin-end keywords). A brace (etc.) triggers an indent. The author suggests newline/indent for single statement condition/loop bodies without using braces, that causes me to stall, just as much as I would have if people were using braces without indenting (but that never happens).
Aside from that, I essentially agree with him.
|
|
|
|
|
Other things being equal, readability is a desirable end.
A lot of the time LINQ and other functional approaches can make code more readable. But sometimes you're better off doing it the long way. I've often gone for a LINQ solution and then decided that the readability suffers and then backed out.
But sometimes you reach a sweet spot where your succinct code is simultaneously more concise, more expressive, more readable and more robust.
Kevin
|
|
|
|
|
Astronomers have produced a remarkable new image of Jupiter, tracing the glowing regions of warmth that lurk beneath the gas giant's cloud tops. "In place of a Dark Lord, you would have a Queen! Not dark, but beautiful and terrible as the Dawn!"
|
|
|
|
|
Kent Sharkey wrote: "In place of a Dark Lord, you would have a Queen! Not dark, but beautiful and terrible as the Dawn!" My treassssure...
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
In an update to its driver shiproom schedule, Microsoft has blocked out May 26-28 as a Feature Update timeframe. Just in case you want to (temporarily) disable Windows Update
|
|
|
|
|
As developers come together to help the world solve new challenges, sharing knowledge and staying connected is more important than ever. Join your community to learn, connect, and code—to expand your skillset today, and innovate for tomorrow. Find out what they want you to build in the future
I'm assuming, "Azure, Azure, Azure". Oh, and they're due to have a new Windows coding framework - XAML/Silverlight/UWP/WinUI are getting old. Maybe a retro-"back to Winforms" movement?
|
|
|
|
|
DevOps -- which syncs, organizes and automates the pace of software releases -- 'is by default built for remote operations' such as that required for the COVID-19 crisis. However, DevOps skills have been hard to find. When your best moment is when no one is at work to appreciate it?
|
|
|
|
|
Kent Sharkey wrote: However, DevOps skills have been hard to find.
I think the author meant to say "hard to justify". I don't know any developer that thinks we (developers) have any business doing anything other than writing code.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Redmond adds protection against massive "Reply-All" email storms after suffering two internal incidents in 2019 and 2020. And we have an early entrant for next year's Nobel Peace Prize
|
|
|
|
|
Quote: Microsoft adds protection against Reply-All email storms in Office 365 Why?... That's not a bug, it is funny.
They should start fixing real errors.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: They should start fixing real errors. Good point. Every single Microsoft employee worked on that feature. None of them are working on bugs.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Well MS recently released a hack for the bug that the windows installer only installed a browser download tool instead of Chrome.
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 sounds like MS is almost trying to take on the role of the Criminal Rehabilitation Social Worker from A Clockwork OrangePR Deltoid being a good friend to you as always, the one man in this sore and sick community who wants to save you from yourself.
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
|
Highlander would say: "There can be only one!"
|
|
|
|
|
In the next round, I guess they will go to a library to study fiction novels, discovering that the variation in book size is very little. All novels of some quality comes with (at least optionally) hard covers. They all have a colophon and a title page, and the kind of information presented in both is very uniform across a large number of books. A large number of novels have a list of chapters before the main contents. The main contents is very uniform: It almost without exception consists of letters put together as words, which are strung up as sentences. A handful of sentences make up a paragraph, and a sequence of paragraphs make up a chapter. The chapters usually have an identifier, which may be alphabetic, from a single word to a full sentence, or a positive integer, montonously incremented in steps of one.
I am quite sure that such a study could earn you an Ig-Nobel prize.
|
|
|
|
|
You may even be awarded a Nobel prize in Literature. Such an article would make better reading than much of the crap opuses that pass under that name these days.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
They may as well have called that article, "We're Trying Hard to Justify or Existence".
Sites look more similar now because of "standards" that everyone seems to have more or less accepted, such as the "hamburger menu".
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: such as the "hamburger menu". 1 Bigmac, please
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Three words: Free Bootstrap Template
|
|
|
|
|
The botnet consisted solely of D-Link NAS and NVR devices and the botnet peaked at 10,000 bots in 2015. I know I've said that "everyone needs a hobby", but some people need better hobbies
|
|
|
|