If we're linking to different coding conventions/styles, I'm a big fan of the ones John Carmack wrote out for the Doom 3 team. While it doesn't all apply to Lua, much of it does (just as with Torvalds').
http://fd.fabiensanglard.net/doom3/Code ... ntions.pdf
(Original .doc version: ftp://ftp.idsoftware.com/idstuff/doom3/ ... ntions.doc )
More info on that in practice here: http://kotaku.com/5975610/the-exception ... ource-code
Then again, I'm a bit of a Carmack fanboy
Laying out code opinions?
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Laying out code opinions?
Lesson learned? If you ask programmers about their opinion on anything, you'll get a holy war. So why bother?Eamonn wrote:I didn't make this thread for people to tell each other whether their style was wrong or not, I made it so I could see how the majority type their code.
Help us help you: attach a .love.
Re: Laying out code opinions?
'cause if you're smart, you can use their holy war style posts to learn something worthwhile.Robin wrote:Lesson learned? If you ask programmers about their opinion on anything, you'll get a holy war. So why bother?Eamonn wrote:I didn't make this thread for people to tell each other whether their style was wrong or not, I made it so I could see how the majority type their code.
Working together and communicating are pretty crucial for anyone who wants to program in a team, so it's good to learn how others people do their stuff. And to make a few rules about it when you start up a combined project. I've really learned to appreciate using a specific style of formatting, because the one they have at my job might not be my favorite, and I do it completely different at home, but the fact that everyone in the team uses the same style makes code so much easier to read that it's totally worth it.
Re: Laying out code opinions?
I was working on a game in a team, but that died People left because others fought, and it went from like 6 to 2 in a week. So it ended up I got fed up. I don't care how other people lay out their code, as long as it's indented. Maybe it's just me coming from Python, but I like 4 whitespaces No idea why. Anything over 4 is too much IMO.Plu wrote:'cause if you're smart, you can use their holy war style posts to learn something worthwhile.Robin wrote:Lesson learned? If you ask programmers about their opinion on anything, you'll get a holy war. So why bother?Eamonn wrote:I didn't make this thread for people to tell each other whether their style was wrong or not, I made it so I could see how the majority type their code.
Working together and communicating are pretty crucial for anyone who wants to program in a team, so it's good to learn how others people do their stuff. And to make a few rules about it when you start up a combined project. I've really learned to appreciate using a specific style of formatting, because the one they have at my job might not be my favorite, and I do it completely different at home, but the fact that everyone in the team uses the same style makes code so much easier to read that it's totally worth it.
Really, the only thing you need to remember when programming is to always indent. I spent about 2 hours indenting MBG correctly(I was using ZeroBrane that day, and it was indenting at 2 instead of 4), and so I saved it, opened it in Sublime Text and it was messed up again. I always try to keep my code indented right. It helps when debugging a lot.
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Laying out code opinions?
Doom, wonderful days of Doom. I programmed in C, so I got used to the doom-style layout. Ahhhh good old days.scutheotaku wrote:If we're linking to different coding conventions/styles, I'm a big fan of the ones John Carmack wrote out for the Doom 3 team. While it doesn't all apply to Lua, much of it does (just as with Torvalds').
http://fd.fabiensanglard.net/doom3/Code ... ntions.pdf
(Original .doc version: ftp://ftp.idsoftware.com/idstuff/doom3/ ... ntions.doc )
More info on that in practice here: http://kotaku.com/5975610/the-exception ... ource-code
Then again, I'm a bit of a Carmack fanboy
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
Re: Laying out code opinions?
+1Davidobot wrote:Doom, wonderful days of Doom. I programmed in C, so I got used to the doom-style layout. Ahhhh good old days.scutheotaku wrote:If we're linking to different coding conventions/styles, I'm a big fan of the ones John Carmack wrote out for the Doom 3 team. While it doesn't all apply to Lua, much of it does (just as with Torvalds').
http://fd.fabiensanglard.net/doom3/Code ... ntions.pdf
(Original .doc version: ftp://ftp.idsoftware.com/idstuff/doom3/ ... ntions.doc )
More info on that in practice here: http://kotaku.com/5975610/the-exception ... ource-code
Then again, I'm a bit of a Carmack fanboy
Re: Laying out code opinions?
Why not indent with tabs? changing your editors tab width setting is maybe easier than adding whitespaces everywhere by hand.Eamonn wrote:Maybe it's just me coming from Python, but I like 4 whitespaces No idea why. Anything over 4 is too much IMO.
Really, the only thing you need to remember when programming is to always indent. I spent about 2 hours indenting MBG correctly(I was using ZeroBrane that day, and it was indenting at 2 instead of 4), and so I saved it, opened it in Sublime Text and it was messed up again. I always try to keep my code indented right. It helps when debugging a lot.
experimental art since 13.75 gigayears
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
Re: Laying out code opinions?
My editor adds whitespace tabs for me when I press tab. It would also auto-ident when I press enter or use curly brackets. Benefits of whitespaces is that it doesn't explode if you decided to retype anything inline-tabbed. Also, using inline tabbing and having literal tabs is pretty much mutually exclusive anyway because with them it'll only displayed correctly on your notepad.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Laying out code opinions?
You mean aligning? It's better to use spaces for that anyway. I don't usually align things, but when I do, this is my modus operandi:raidho36 wrote:Also, using inline tabbing and having literal tabs is pretty much mutually exclusive anyway because with them it'll only displayed correctly on your notepad.
Code: Select all
function hodor()
--->if verylongveryverylong and
--->...somethingelsethatislong then
--->--->functioncall(longargument1,
--->--->.............longargument2,
--->--->.............longargument3)
--->end
end
Help us help you: attach a .love.
Re: Laying out code opinions?
The problem with tabs is that people say "oh, just change your editor's tabstops", and then it turns out they mix & matched tabs and spaces. For instance, lets look at what robin just did, but with 8 char tabs:
And again with 2 space tabs:
Heaven help us when tabs and spaces are used at the end of the line to align comments.
Code: Select all
function hodor()
------->if verylongveryverylong and
------->...somethingelsethatislong then
------->------->functioncall(longargument1,
------->------->.............longargument2,
------->------->.............longargument3)
------->end
end
Code: Select all
function hodor()
->if verylongveryverylong and
->...somethingelsethatislong then
->->functioncall(longargument1,
->->.............longargument2,
->->.............longargument3)
->end
end
Last edited by Inny on Wed Jul 03, 2013 11:31 pm, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 3 guests