|
Generally speaking, long names don't always make a problem, but it does crop up now and then. I don't like to split an operation, so I wont split at the dots either. I would much rather have a long line that clearly displays the operation being performed, than break it up onto a number of lines. Again, in such a case, I will attempt to use the most atomic operations possible, to help keep the lines as short as possible.
When breaking a string up, for example in C#, you need to end the string on each line, and add a '+' for each following line. This is runtime concatenation. I do believe there are other compilers (VB?) that will perform the concatenation at compile time, so that would depend on the compiler, I guess.
|
|
|
|
|
In Eclipse, I hit the reformat command all the time. Whatever the settings are, that's what happens. (I do tinker with the settings at first, but once done I just let it do its thing.)
This makes the comments go all wonky sometimes, but that's not too important.
Visual Studio has really, really sucky reformatting. Pisses me right off, it does.
Recently started using NetBeans, and it's somewhere between Eclipse and VS.
If I'm using TextPad, then I use line breaks depending on my mood. I hate horizontal scrolling, but if all I have is text (such as a print statement), I may keep it on a single line to avoid wasting too much vertical space.
Basically, I format using the 1TBS.
Don't let my name fool you. That's my job.
|
|
|
|
|
I don't know about Eclipse, but in Visual Studio, once you break an operation onto multiple lines, formatting will not make any changes to the number of lines, nor will it decide if a line is too long and break it up.
I use Visual Studio all the time, and I have never had a problem with the formatting. Then again, I started programming in VS, so I guess my formatting preferences are based on what is available in VS.
|
|
|
|
|
I started programming a little bit before Visual Studio, but not too far: it was in the Trash 80 command line. Forget punch cards, some of the older guys literally had to wire their own boards to make a program.
The refusal to un-break lines is minor compared to the forcing of a bad bracing style.
Not being a total dick, I define "bad" here to mean "one that I don't want to use", rather than one that is actually bad. Eclipse has a default, but allows you to customize that to whatever you want.
I developed my own personal style before I ever got on the Internet, and I was surprised to discover that it very closely aligned with the 1TBS.
Would it kill MS to give people more flexibility? Sheesh.
Don't let my name fool you. That's my job.
|
|
|
|
|
From your choice of wording, I'm going to assume you are not aware that VS allows you to customize the formatting as well? This can be done on a per-language basis, using the Tool -> Options... -> Text Editor -> [Language] -> Formatting.
I wasn't actually aware that there were names given for different styles of formatting, such 1TBS, so I went to wikipedia[^] to find out more (you learn something new everyday, huh?). Apparently, my style is actually mostly my own: I use the Allman style mostly, but have a few things I do differently, although I'm not sure where I got them from.
|
|
|
|
|
but when I checked it I realized I had seen it already. It's nothing close to enough.
I'm guessing you've never seen Eclipse' formatting options. It's primarily a Java IDE, but it's free, so you should take a look if you get a chance.
THAT is how code editors should be. At least for formatting options.
There are things I cannot do well (or at all) in it that I can do in VS, or more often better in TextPad. But on the whole, it is very tunable for the programmer's taste.
Sun's NetBeans IDE is a bit more like VS in that they want to prescribe what you have to use, but let you have a tiny amount of control.
Don't let my name fool you. That's my job.
|
|
|
|
|
Not having seen the options available in Eclipse, I thought VS provided a lot of options. Now, having seen Eclipse (a colleague had it installed), I agree with you that that is how formatting options should be.
Especially the separate window, clearer options, easier display, and the fact that all changes affect the example - in VS, each option's example uses the basic formatting, and only changes what is currently under selection.
I guess we can 'hope' that someone at Microsoft sees other IDEs and their available options, and does something about it in one of the upcoming versions.
|
|
|
|
|
Also depends on the language for me. Complex SQL statements, xml CDATA, etc. can be tricky to limit. Some older compilers also freak out with too many concatenations / line continuations.
|
|
|
|
|
I know it's deeply unfashionable, but I still print code - especially if I have to stare at some gnarly logic constructions. Of course those are (mostly) in other's code , so I may have to reformat to even get there.
Overall, I think every so often its good to look at the page rather than the screen to give my eyes a break.
|
|
|
|
|
Can I ask why you can't print anything wider than 80 characters? I just see 80 characters as so 1970s. I mean I limit my widths, but I'll be crazy enough to go to 100 or even 120.
|
|
|
|
|
Well, I guess that just depends whether you like "super-size" fonts or not. Maybe time for me to get that prescription checked. The spectacles one, anyway.
|
|
|
|
|
Old Nic wrote: Well, I guess that just depends whether you like "super-size" fonts or not.
Oh yeah, good point. Well, maybe we can all meet in the middle with 100.
|
|
|
|
|
is a bit less than what fits in each of 2 vertical panes in VS2008 editor, I usually have solution explorer docked to the right and like most folks I avoid horizontal scrolling, running a 24" monitor @ 1920x1200. That number of chars also prints comfortably on A4.
|
|
|
|
|
A tip for anybody who wants to see where the column end is: Guidelines in VS[^]
I have red guidelines at columns 80 and 120. I try to stick to my self-imposed 120 column limit, but not at any cost.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
A Blessing On Your Head !
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
I find it so useful and love it so much, I can't believe MS didn't include the setting in Tools-Options. It's been there since VS 2003 at least!
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
The link seems problematic at the moment; could you just describe how to do that?
|
|
|
|
|
Does even the google cache[^] not work? Here's the text:
Enabling Guidelines
First, shut down Visual Studio 2005 if already started.
Under
[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\8.0\Text Editor
Create a string value called
Guides
Set Guides to the following
RGB(x,y,z) n1,...,n13
Where x,y,z are the RGB values and n is the column number. You can have at most 13 guidelines.
For example,
Guides = RGB(128,0,0) 5, 80
will place a Red guideline at column numbers 5 and 80.
And now launch VS and open a text file.
Disabling Guidelines
An obvious no-brainer, just delete the Guides keys you created above. Restart VS, and no more guidelines.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Excellent tip - i've been using those for several years now, greatly reduces the chance that i'll end up with an unpleasant surprise when moving between resolutions.
---- You're right.
These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets .
|
|
|
|
|
Where do I tell it to stop the crappy formatting that it does and use my preferred style?
Don't let my name fool you. That's my job.
|
|
|
|
|
Tools|Options|Boot to the head
|
|
|
|
|
Are you using the Canadian version? I'm frantic trying to find it.
Don't let my name fool you. That's my job.
|
|
|
|
|
It seems I can fit 229 characters across my (20") screen in VS, using Andale Mono at 8 point.
But I can only fit 112 across 7.5" of paper (8.5" with .5" margins), so I use that, have for years, even when using a VT340 VT320 set at 132 columns.
modified on Tuesday, January 27, 2009 12:01 AM
|
|
|
|
|
I started limiting the width because of Python PEP0008, but then I realised it's a damn good idea. I've got a line somewhere that's something like:
atta = charset[source]["stats"]["baseattack"] + weaponset[charset[source]["equipment"]["weaponID"]]["attackboost"] + armourset[charset[source]["equipment"]["armourID"]]["attackboost"]
Or at least, it would be, without limiting it to 79 characters.
My current reason is, if I ever do work on joint projects, or anyone wants to read my code, it's rude to make them scroll sideways. Sideways scrolling is the work of the devil.
EDIT: Haha, I also now realise the irony that someone will need to scroll sideways to see the entire line. Oh well, the presence of a horizontal scrollybar at the bottom of the screen is proof enough, of my point.
|
|
|
|
|
Ha! I write my whole program on one line, because I have dual 50" monitors and I just like to drive the point home.
|
|
|
|
|