Click here to Skip to main content
15,894,362 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
JokeRe: Christmas Carol of The Day: Pin
Daniel Pfeffer20-Dec-21 4:42
professionalDaniel Pfeffer20-Dec-21 4:42 
GeneralExpression bodies vs Good Old Fashioned Functions Pin
Chris Maunder20-Dec-21 4:00
cofounderChris Maunder20-Dec-21 4:00 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
k505420-Dec-21 4:14
mvek505420-Dec-21 4:14 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 5:23
trønderen20-Dec-21 5:23 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Mark Whybird21-Dec-21 16:19
Mark Whybird21-Dec-21 16:19 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slow Eddie20-Dec-21 4:23
professionalSlow Eddie20-Dec-21 4:23 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
ElectronProgrammer20-Dec-21 6:03
ElectronProgrammer20-Dec-21 6:03 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 6:25
trønderen20-Dec-21 6:25 
Chris Maunder wrote:
This makes me feel old because it reminds me of when we used to cram our code into as small a space as possible to handle 25 line screens.
I do appreciate fitting an entire function/method on the screen, especially when I didn't write the code myself (or I wrote it so long ago that I no longer remember my line of thought), and need to read the code forwards and backwards and from both sides to understand the logic.

With the 60+ line editor windows of today, you'd think that was a modes request. But with the modern style of always putting braces on separate lines, always put braces around even a simple assignment if it is e.g. an if clause (so the minimum number of lines for an if statement is 4). Some people even insist on always putting blank lines before and after any 'structured' statement (such as if/else, loops etc.), making 5 (or even 6, depending on context) the minimum line count for a simple 'if' ... Then you certainly won't be able to fit any large fraction of real-life methods in a 60 line editor window, or the hardcopy equivalent: One printed page. If you also forbid end-of-line comments, requiring comment to have their own lines (this has been the case in the majority of projects I have worked on, you frequently see 60 line windows "crammed with code" (according to the coding standard, but really containing no more than 5-8 statements.

When I write code independent of such spacing requirements, I succeed in fitting maybe half of the function bodies below 60 lines. Then I e.g. put the opening brace at the end of the first line, and I accept un-braced single assignments as if/else clauses, following the condition or the 'else' keyword on the same line. A short (typical: half line) comment is written from col 70 of the line to which it applies, or col 90 if many source lines are long - I want the option to 'semi-ignore' the comments; when I know the code, comments should be there, but no clutter up the actual code statements.

If I want people to review code written this style, I may print it double spaced (today, when most code reviews are made on-screen, I can just replace every newline with two newlines), to give other developers something in that 'airy' style that they want. No one ever remarks anything about blank lines around all statements, not just structured ones. That makes every statement clearly defined. It is considered making the code 'easier to read' (just like children's books usually has significantly larger line spacing than books for adults).

I knew one guy who was almost totally blind, yet an eager program developer. He read (and edited) the source code on a braille line: With his fingertips, he could read one line at a time, scrolling up and down a line at a time. He sort of kept the entire source code inside his head, using the braille line primarily as a tool for finding the right spot for his corrections or amendments.

When I read that airy kind of code, newlines as frequent as spaces, where I have to page down, and down, and more down, ... and then return to maybe six pages higher up, I feel a close relationship with my almost-blind friend: I must keep structure of the code in my head. I won't have the option to see it on the screen. Not unless I get myself a minimum of three huge, high resolution screens, stacked one above the other, in portrait orientation. And a ladder to climb up and down the code strand.

A common APL joke is that every APL programmer's dream is to write the entire problem solution in a single line. It looks as if a fair share of C programmers' ultimate dream is to write the entire problem solution in a single column.
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
David O'Neil20-Dec-21 6:48
professionalDavid O'Neil20-Dec-21 6:48 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Rich Shealer21-Dec-21 2:46
Rich Shealer21-Dec-21 2:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
David O'Neil21-Dec-21 12:40
professionalDavid O'Neil21-Dec-21 12:40 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:15
James Lonero23-Dec-21 7:15 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Marc Clifton20-Dec-21 8:46
mvaMarc Clifton20-Dec-21 8:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:54
professionalSlacker00720-Dec-21 8:54 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 12:22
trønderen20-Dec-21 12:22 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Peter Adam20-Dec-21 20:30
professionalPeter Adam20-Dec-21 20:30 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:39
James Lonero23-Dec-21 7:39 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:12
James Lonero23-Dec-21 7:12 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Gary R. Wheeler20-Dec-21 7:14
Gary R. Wheeler20-Dec-21 7:14 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:59
professionalSlacker00720-Dec-21 8:59 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Leo5620-Dec-21 23:57
Leo5620-Dec-21 23:57 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
dan!sh 20-Dec-21 22:11
professional dan!sh 20-Dec-21 22:11 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
MadGerbil21-Dec-21 1:47
MadGerbil21-Dec-21 1:47 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:51
professionalrjmoses21-Dec-21 10:51 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:54
professionalrjmoses21-Dec-21 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.