Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411485 Posts in 69371 Topics- by 58427 Members - Latest Member: shelton786

April 24, 2024, 04:29:46 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The "Elegant" Code Thread
Pages: 1 2 3 [4]
Print
Author Topic: The "Elegant" Code Thread  (Read 5778 times)
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #60 on: November 24, 2017, 07:30:13 AM »

oohh I see what you mean. I've felt that pain a bit. I used to align all my member declarations using tabs but auto format would mess all that up or someone would autoformat and submit it to source control.

It's too bad I really liked that formatting for members and variables. Kind of looked like a spreadsheet.

If you make that plugin for VS I'd be interested Smiley

I found CodeAlignment plugin:
https://marketplace.visualstudio.com/items?itemName=cpmcgrath.Codealignment

but I did not try it yet, and I cannot find if this works for comments. But in this one:
https://marketplace.visualstudio.com/items?itemName=wwm.better-align
the GIF shows that works for comments also.

Cool! that's exactly what I'm looking for.

Now the only issue is getting everyone else to use it haha :D

Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #61 on: November 25, 2017, 12:56:11 AM »

Ahah, same here! When I showed that plugin to the others, they replied that it could be a pain if someone wants to edit something and does not have the plugin, but I do not think that 3-more spacebar on your keyboard will hurt your finger  Tongue
Logged

Games:

Crimsontide
Level 5
*****


View Profile
« Reply #62 on: November 26, 2017, 12:00:06 AM »

To be honest I wish we could get beyond this.  I imagine a version control type of system, where when all code is checked in all white space (except for comments) and formatting is removed.  Then when you check it out, you can select your code/formatting style.  There could be a set of pre-set styles (ie. google style, MS style, freestyle, whatever) and people could write their own formatters.  Code internally would actually be stored in a AST or similar format.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #63 on: November 27, 2017, 07:53:57 PM »

To be honest I wish we could get beyond this.  I imagine a version control type of system, where when all code is checked in all white space (except for comments) and formatting is removed.  Then when you check it out, you can select your code/formatting style.  There could be a set of pre-set styles (ie. google style, MS style, freestyle, whatever) and people could write their own formatters.  Code internally would actually be stored in a AST or similar format.

You kind of do that with perforce (essentially just calling a formatter on a submit/checkout trigger). Storing it internally as an AST is an interesting concept though. I never thought about that before.

Logged

bateleur
Level 10
*****



View Profile
« Reply #64 on: December 04, 2017, 09:37:00 AM »

The trouble with that kind of approach is that it assumes code formatting adds no information. And, indeed, it doesn't if you do it badly.

People can be very dogmatic about formatting, and a lot of choices either genuinely don't matter or what's best varies with language and task... but good formatting can massively improve productivity. Improved code readability makes bugs easier to spot and if comments are easy to write and look nice then code ends up better commented.
Logged

ferreiradaselva
Level 3
***



View Profile
« Reply #65 on: December 04, 2017, 11:38:59 AM »

John, that uses 2 space bars as indentation, unsurprisingly write functions that are deep nested, noticed Megan, that uses 8-width tab bar as indentation.
Logged

Pages: 1 2 3 [4]
Print
Jump to:  

Theme orange-lt created by panic