I have a few code files that are rather large in length. The one I have open right now is approaching 750 lines and is growing quickly. I'd rather not split the class among multiple files, doing that just makes me nuts (even when VS puts the control declarations in the separate file makes me nuts, I wish I could turn that off), having to move between tabs to compare code (yeah I know you can split the screen but that makes me even crazier).
I was wondering if anyone had any tricks to make it easier to find methods or regions in the code file without searching forever. Either colour schemes or anything!
I'm one of those code writers that people seem to hate looking through my source, just because I LOVE space. I always put my brackets on a line of their own, my "get set"s used to take 8 lines, now they just take 4, but that's still a lot for some people.
I also had a bad experience once of reviewing code that I had written back in 2008-2009 and practically documented nothing, except for obvious things, and even then the comments were useless, like before a confirmation message box I'd put "Make sure the user isn't an idiot!"
I've gotten into the habit of documenting the purpose of methods (XML Comments) and parameters etc.. but only comment unobvious things inside my methods. But I'm worried that I'm not documenting enough, because what's obvious now, might not be later.
Anyway, are there any suggestions or ideas for:
Easier code reading using fonts, backgrounds etc... in the code editor so when I am visually scanning a code file I know if I moved from one region to the next or something.
What should be commented on, what should not be commented on?
I know I asked before and it seemed that many people did the same as me, but how do you organize your methods? Alphabetically? Logical order (what logic?)? Just the order you wrote them (your nuts in my opinion if you do that)? Do you use regions? If you use regions, what do you group by and do you have subregions?
I'm just soliciting ideas and suggestions, I know there really is no "Standard" it's just whatever works for you, but when I'm working in the code files, I alphabetise my methods and organize them into regions, but obviously what I am doing doesn't work well enough so I just wanted to see what other people did.
Ideas and maybe even skeleton code files would be cool. Screen shot colour schemes would be nice too if you feel ambitious! :)
I appreciate ahead of time anyone who wants to share their tricks for working quickly in their code files.
Most seasoned professionals would tell you:
1) to NOT use regions
2) to break your code up into chunks of functionality
3) to break up your functions into separate files
4) to use self-documenting/intuitive code rather than commenting.
5) that modern tools remove the need to sort your code
This blog post disagrees with the one you posted. So which is right? For me, it depends on what you are using regions for. If it is to hide code in the middle of a method (something I've never seen anyone do) then I'd agree, it's bad. But to organize your code into groups I'd say is good.
I do divide my code using regions, I group things similarly to how Momerath does. It works well, but it's kind of a drag when the file is nearly (or over) 1000 lines and you need to find a method in the middle of the file for whatever reason and you scroll.....slowly....until you find it. I just wish there was a way to change the background colour of every other method or something, or highlight the text inside of a region with some sort of color you could set, like #Region Some Name [BG:Red] or something so that, without looking at the top of the region to find out what region you are looking at.
I know, I know, the code should be obvious just by looking at it what region it's in, but if I was looking for the red region, I could scroll faster until I just saw red, and knew it was the one I was looking for.
I do appreciate the feedback though! What colour schemes do you guys use for your code editor? Or do you just use the default (that's what I use).