Laying out code opinions?
Re: Laying out code opinions?
Actually, it does still look good. I guess I derped with my example.
On another note, there's a thing I read about once called Elastic Tabstops, where by there's a bit of intelligence done into how many spaces are a tab, so that you don't have to anything more than add a single tab in order to get all of your comments to align.
Of course, commenting at the end of the line is falling out of popularity anyway. I guess tabs are alright as long as they occur at the start of the line, match the nesting level, and then no more.
On another note, there's a thing I read about once called Elastic Tabstops, where by there's a bit of intelligence done into how many spaces are a tab, so that you don't have to anything more than add a single tab in order to get all of your comments to align.
Of course, commenting at the end of the line is falling out of popularity anyway. I guess tabs are alright as long as they occur at the start of the line, match the nesting level, and then no more.
Re: Laying out code opinions?
i admit i use pure whitespace too, tabs confuse me too much.
When in doubt i just press gg=G in vim and everything gets autoindented, afaik this can also be controlled with the "tabstop" setting.
I dont have a masterplan for aligning = or comments yet, i tend to align then but not sure if its a good idea.
When in doubt i just press gg=G in vim and everything gets autoindented, afaik this can also be controlled with the "tabstop" setting.
I dont have a masterplan for aligning = or comments yet, i tend to align then but not sure if its a good idea.
experimental art since 13.75 gigayears
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Laying out code opinions?
I always indent with 2 spaces.
And I also align all the commas, colons and equal signs when it makes sense. It helps visually finding stupid bugs ("these two should be aligned and they are not ... oh, wait, I forgot an s here").
I have editor commands for transforming tabs to 2 spaces, re-indenting code selections, and aligning stuff, so I do that without thinking very much of it.
And I also align all the commas, colons and equal signs when it makes sense. It helps visually finding stupid bugs ("these two should be aligned and they are not ... oh, wait, I forgot an s here").
I have editor commands for transforming tabs to 2 spaces, re-indenting code selections, and aligning stuff, so I do that without thinking very much of it.
When I write def I mean function.
Re: Laying out code opinions?
Dissident here. I write my code with everything right up against the left side, no spaces around my equals signs, and usually no comments below the top two lines. This rarely results in write-only code, but I figure that if it does then I just need to learn the language better.
I would like to further add that I don't even use a code editor. I always get confused when people talk about their EMACS keybindings and how they couldn't live without their shortcuts in Vim, because I program just fine in Leafpad (a GTK clone of Notepad). I have tried these advanced code editors, but none of the functions they offered could get me past the fact that most of them add a linebreak to the end of the file when I don't want one there, or recolor the text in a manner that is irrelevant to my task, or just take too long to start.
Maybe I'm a bad programmer, maybe not. I can't really say, but I certainly have plenty of time to find out.
I would like to further add that I don't even use a code editor. I always get confused when people talk about their EMACS keybindings and how they couldn't live without their shortcuts in Vim, because I program just fine in Leafpad (a GTK clone of Notepad). I have tried these advanced code editors, but none of the functions they offered could get me past the fact that most of them add a linebreak to the end of the file when I don't want one there, or recolor the text in a manner that is irrelevant to my task, or just take too long to start.
Maybe I'm a bad programmer, maybe not. I can't really say, but I certainly have plenty of time to find out.
Re: Laying out code opinions?
i use tabs but i don't have this problem because i don't do alignment like thatInny wrote: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:Code: Select all
function hodor() ------->if verylongveryverylong and ------->...somethingelsethatislong then ------->------->functioncall(longargument1, ------->------->.............longargument2, ------->------->.............longargument3) ------->end end
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
anyway i guess this is representative of my coding style. it's horrible
Re: Laying out code opinions?
Hello, Zuko here. I code with four spaces always so I can restore my honor.
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Laying out code opinions?
My coding style is pretty much the same as other people who use tabs.
Didn't put a table variable in the AS3 one because I kinda forgot
Code: Select all
local hi = "hello"
local hello = "hi"
function foo(bar)
print(bar)
end
local table = {
x = 0,
y = 0
}
-- In AS3
private var hi:String = "hello";
private var hello:String = "hi";
private function foo(bar:String) {
trace(bar);
}
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
Re: Laying out code opinions?
I don't use AS3 very often, but when I do my style is the same as yours. Same goes for Java, C++, etc(though I never use C++, I might try to get back into it again ).substitute541 wrote:My coding style is pretty much the same as other people who use tabs.
Didn't put a table variable in the AS3 one because I kinda forgotCode: Select all
local hi = "hello" local hello = "hi" function foo(bar) print(bar) end local table = { x = 0, y = 0 } -- In AS3 private var hi:String = "hello"; private var hello:String = "hi"; private function foo(bar:String) { trace(bar); }
What theme's do people use as well, and text editors? Just another curiosity thing! I use SublimeText2(I'm hoping to buy it soon and get ST3 to support the devs) and I constantly switch between themes, but the ones I use most commonly are:
Cobalt
All Hallows Eye
Tomorrow-Night-Eighties
Tomorrow-Night-Blue
Solarized(Dark)
Expresso Libre
I like to code on dark(ish/er) colours, because coding on a white background annoys my eyes after a while. I also tend to have a darker brightness level(unless I'm debugging, then that baby goes up the full way!!). Though I do use my backlit keyboard at night. I also really, really, really, really, really, really, REALLY REALLY like blue. Like, a LOT! Any blue themes for ST2 are löved by me!
"In those quiet moments, you come into my mind" - Liam Reilly
Who is online
Users browsing this forum: No registered users and 0 guests