|
see my signature
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
|
|
|
Hi All,
Trying to post a question and get Quote:Quote: There was an internal error creating the item. Umm Huh, try a repost to see if it's the web our end a few moment ago I got Quote: easy tiger you are reposting to often
...I know has his own way with error messages ("there is no spoon" springs to mind) but... Also the Preview doesn't work?
|
|
|
|
|
Is the question too long, too short, contains odd characters ... ?
|
|
|
|
|
Nope, just some code in the proper tags.
|
|
|
|
|
I had that same issue yesterday.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I feel better about that doesn't hate me
|
|
|
|
|
Same actually.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Maybe has still hangover?
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.
|
|
|
|
|
From CP newsletter
https://www.codeproject.com/News.aspx?ntag=19837497829658814&_z=2928472[^]
They want to run their monitors in a diagonal mode because?
"Why 22 degrees? At that angle, you get the longest line length (stretching between opposite corners)"
My answer to that - your line is too long. Make it shorter. You are not writing code for you but are writing it for the people in the future that must maintain it.
|
|
|
|
|
Not just no but hell no!
As the aircraft designer said, "Simplicate and add lightness".
PartsBin an Electronics Part Organizer - Release Version 1.3.0 JaxCoder.com
Latest Article: SimpleWizardUpdate
|
|
|
|
|
At most one line that length.
Try a smaller font -- I use 8pt. I also try to limit my line lengths to 112 characters. I used to use VT screens set to 132 characters per line.
132 characters per line ought to be enough for anybody.
|
|
|
|
|
With a readable size font, my maximum line length is 544 characters with 135 lines on the screen. I could do more with a slightly smaller font or perhaps a different font. That is not to say that I have written lines that long, I don't actually know how long that would be. We are not using punched cards anymore, we are not restricted to fan-fold paper -- who actually uses paper anymore? There is no unacceptable maximum for either the number of lines in a method / function or the length of a line. In both cases, I would expect the set of lengths to be a power distribution. Where the vast majority of function / line lengths are very short, and very long lengths would be extremely rare -- but no upper limit. The length of either a function or a line should be considered on a case by case basis.
There are many times that the most important information in a line of code occurs in the first 20 or 30 characters. The best readability may be a very, very long line because the majority of the time the remainder of the line is not of interest when reading code.
If there is a problem with lines that are too long, get a better monitor. My primary monitor is a 50" 4k monitor (actually TV, but that replaced a failed 48" 4k monitor because it was something like $200 instead of $2000). When available, and when I can afford it, my next monitor will be 55-65" and 8k. Even without a better monitor, just scroll left / right or up / down.
|
|
|
|
|
Member 11816776 wrote: There is no unacceptable maximum for either the number of lines in a method / function or the length of a line.
By that argument then every code file you write should be one line.
But the real argument in a business environment is that you are not writing code for yourself. You are writing it for the company. Which is why they pay you.
And unless you are a deity someday someone else will need to modify that code. Matter of fact studies have shown that the cost of maintaining code is between 2 and 100 times as much as creating it in the first place.
And the company must pay that.
So a responsible professional developer should create code that one can reasonably be maintained by a future programmer and not the original author.
Member 11816776 wrote: There are many times that the most important information in a line of code occurs in the first 20 or 30 characters. The best readability may be a very, very long line because the majority of the time the remainder of the line is not of interest when reading code.
And yet your very statement points out that the rest of the line can be important.
Member 11816776 wrote: If there is a problem with lines that are too long, get a better monitor
No the solution then is during the code review to tell the author to reformat the line so it is shorter.
I have even seen one review process where long lines could not even be viewed so one had to pop to view the file then find the line.
|
|
|
|
|
Obviously, this person has never seen how Microsoft writes long lines. For example,
HRESULT Scene::CreateDeviceDependentResources()
{
HRESULT hr = m_pRenderTarget->CreateSolidColorBrush(
D2D1::ColorF(1.0f, 1.0f, 0),
D2D1::BrushProperties(),
&m_pFill
);
if (SUCCEEDED(hr))
{
hr = m_pRenderTarget->CreateSolidColorBrush(
D2D1::ColorF(0, 0, 0),
D2D1::BrushProperties(),
&m_pStroke
);
}
return hr;
}
|
|
|
|
|
I have zero problem with that.
In fact, I'd much rather see a function's parameters being broken by parameter (one per line) rather than 3 on the first line, 2 on the second line, then 4 on the third line, etc. If it has to be broken down, go all the way.
Then if a parameter consists of a function call, and that function needs so many parameters of its own that that line becomes long, then break it into multiple lines too, with an extra indentation level.
Seems so logical to me.
|
|
|
|
|
dandy72 wrote: rather than 3 on the first line, 2 on the second line ...
Same for me.
|
|
|
|
|
I can understand the motivation. I've seen, and perhaps perpetrated, something like:
string someString = mything.something().somethingElse().foo().bar().bang().whiz().toString() Which can sometimes lead to very long lines. But any decent optimizer should be able to elide otherwise unused intermediate object so maybe
auto something = mything.something();
auto foobar = something().foo().bar();
auto whiz = foobar().bang().whiz();
string someString = whiz.toString(); is preferable?
But if you're going to keep the long version as a single statement, but write it over separate lines do you prefer putting the . at the end or the start of the line? e.g
mything.something().
foo().bar().whiz().
bang().toString()
vs
mything.something()
.foo().bar().whiz()
.bang().toString()
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
I find that dots and commas and such are easier to see at the start of a line.
I put commas and binary operators (not dots) on their own lines in many cases so they really stand out.
|
|
|
|
|
string someString = mything
.something()
.somethingElse()
.foo()
.bar()
.bang()
.whiz()
.toString()
;
|
|
|
|
|
I like that look.
I try to write my SQL like that but have been leaving the dot-separators on the previous line in code. My thinking was to indicate that the line (command) was not yet finished.
With this style, keeping each line short it is clear that each line is a continuation.
With SQL, I have been cheating on that style to keep like fields on a single line:
...
, fKey
, LastName, FirstName, MidName
, AddrLine1, AddrLine2, City, State, Country, Zip
--, foo
, bar
...
|
|
|
|
|
bryanren wrote: SQL like that but have been leaving the dot-separators on the previous line in code.
lol ...
Really not obvious to me what you meant until I got to your example. I was crunching my brain trying to find when one would have multiple periods.
Yes I use exactly that form for SQL also.
Unlike with other expressions and even with parameters in C#/Java I still tend (always?) to put the comma at the end of the line rather than the beginning.
No real reason although I could state that a comma is not part of an expression.
But then I do it that way for SQL. So no way I can justify it.
|
|
|
|
|
k5054 wrote: do you prefer putting the . at the end or the start of the line?
Beginning.
Makes it visually obvious when skimming that it is part of a preceding expression.
|
|
|
|