Source code formatting and regions
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I use regions for grouping together public methods, private methods, member variables, properties, etc. I never use them to set apart a block of code inside a method - I just mark those with comments. As for formatting, Ctrl K + Ctrl D is your friend. I just wish it would also collapse multiple blank lines into one.
Cheers, Vıkram.
Carpe Diem.
-
I use regions for grouping together public methods, private methods, member variables, properties, etc. I never use them to set apart a block of code inside a method - I just mark those with comments. As for formatting, Ctrl K + Ctrl D is your friend. I just wish it would also collapse multiple blank lines into one.
Cheers, Vıkram.
Carpe Diem.
Vikram A Punathambekar wrote:
As for formatting, Ctrl K + Ctrl D is your friend
What setup is that on? I always use Ctrk E + D.
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I always use regions for methods, contructors, events, properties, variables and constants. This helps if I have to track something in a large code. I think they are good as if someome else has to maintain your code, it will be easy for him/her to understand what all is written in the code and where to find it. As far as tools are concerned, I have not used any. It will be good if people recommend something.
जय हिंद
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I don't use regions (my classes are generally sufficiently short enough not to need them), but I am meticulous about source code formatting. For formatting, StyleManager[^] is worth checking out.
Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"
-
I always use regions for methods, contructors, events, properties, variables and constants. This helps if I have to track something in a large code. I think they are good as if someome else has to maintain your code, it will be easy for him/her to understand what all is written in the code and where to find it. As far as tools are concerned, I have not used any. It will be good if people recommend something.
जय हिंद
Yup, that's more or less why I use them, it make finding code so much easier. Regards, Martin.
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I wrote an AI using neural networks hosted on Amazon EC2 that processes my code and intelligently formats it all correctly. So far it only works with empty files, but I'm hoping to release a beta soon that works with files up to 1 byte long.
Simon
-
I wrote an AI using neural networks hosted on Amazon EC2 that processes my code and intelligently formats it all correctly. So far it only works with empty files, but I'm hoping to release a beta soon that works with files up to 1 byte long.
Simon
Simon: I'll have to wait for the next version as my code is Unicode and I'll need the 2 byte version ;)
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I believe that your classes should be short enough not to confuse you or anyone who reads your code. Large source code can always be divided to smaller modules to complete the same task. (which also increases the readability.) Well that's why I have never needed regions. I also mark public/private members with comments. In my projects, I use StyleCop[^] and I am happy with the results. Hope this helps, Regards.
Always keep the Murphy Rules in mind!
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I really, really, no, I mean REALLY dislike over regionalization, especially nested regions, the work of the devil. I generally only have one region, for properties, since for the most part they are simply accessors for private fields which are in plain view. Other than that, I lay my code out in the same order all the time, constants fields event declarations constructor and constructor related methods (Initialization stuff etc.) public methods private methods overrides properties event handlers. Luckily I only have myself to please, but it works for me.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
With almost religious fanaticism and zeal. I feel that code that isn't formatted properly and documented properly is half a step away from being thrown onto the rubbish pile. Every class without fail is divided as follows:
#region Using Directives
#endregion[scope] class classname
{
#region Enumerations
#endregion#region Fields
#endregion#region Properties
#endregion#region Methods
#endregion#region Static Methods
#endregion#region Constructors
#endregion#region EventHandlers
#endregion#region Private Classes
#endregion
}Destructors are in the same region as the constructors. Every class, method, field, property and event handler (though lately I'm using a lot of automatic properties) are well documented. just my $0.02
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
Regions are a sin! They are the idle work of the devil! The heathen will use regions to falsely reperesent their code as fitting on one printed page, which we all know is a mortal sin against the all mighty coding principles! Do not succomb to the laziness that this false god desires upon you! Pray instead to the god OOD, to guide you in better architecting your house! Marc
-
Regions are a sin! They are the idle work of the devil! The heathen will use regions to falsely reperesent their code as fitting on one printed page, which we all know is a mortal sin against the all mighty coding principles! Do not succomb to the laziness that this false god desires upon you! Pray instead to the god OOD, to guide you in better architecting your house! Marc
Sometimes, you cannot help but have your classes become rather lengthy, Regions are a boon then. Of course, like guns, they can be used for both good and evil.
-
Sometimes, you cannot help but have your classes become rather lengthy, Regions are a boon then. Of course, like guns, they can be used for both good and evil.
Mustafa Ismail Mustafa wrote:
Sometimes, you cannot help but have your classes become rather lengthy, Regions are a boon then.
Well, there is the "partial" keyword now so you can break up the class. :) Ironically, I never use partial myself. Marc
-
Hi: Do you do source code formatting and/or arranging? What about regions, do you think they are good or evil? Why? I'm afraid I'm a bit of an obsessive compulsive as far as source code is concerned, I have my predefined regions and my code must comply with the Microsoft Style Guidelines, which makes programming quite a task! What tools are available to help me on my personal quest for formatting and arranging? Does anyone have more information (apart from whats available on the web site) on how to use NArrange? Regards, Martin.
I'm fond of regions The program I'm busy with at the moment(The brains of my system) i have METHODS that are 4000 lines long, so regions are a must IMHO. I also use regions in every class for private variables, Properties, Constructors, Private Methods, Public Methods, etc
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
I'm fond of regions The program I'm busy with at the moment(The brains of my system) i have METHODS that are 4000 lines long, so regions are a must IMHO. I also use regions in every class for private variables, Properties, Constructors, Private Methods, Public Methods, etc
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
Mustafa Ismail Mustafa wrote:
Sometimes, you cannot help but have your classes become rather lengthy, Regions are a boon then.
Well, there is the "partial" keyword now so you can break up the class. :) Ironically, I never use partial myself. Marc
Marc Clifton wrote:
Ironically, I never use partial myself.
Ditto. It just doesn't register in my mind to do that.
-
That method is the main calculation method for that program... And it IS busted up into smaller parts(Helper methods). It can be further split up, but not at the moment. This biggest reason is that I'm prototyping it using Linq instead of plain old ADO, and I cant pass a Linq result set around. So I'll have to pass the primary keys around, and query again in the helper method itself. That'll be a pain, especially if i need to change a query.
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
That method is the main calculation method for that program... And it IS busted up into smaller parts(Helper methods). It can be further split up, but not at the moment. This biggest reason is that I'm prototyping it using Linq instead of plain old ADO, and I cant pass a Linq result set around. So I'll have to pass the primary keys around, and query again in the helper method itself. That'll be a pain, especially if i need to change a query.
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
I really, really, no, I mean REALLY dislike over regionalization, especially nested regions, the work of the devil. I generally only have one region, for properties, since for the most part they are simply accessors for private fields which are in plain view. Other than that, I lay my code out in the same order all the time, constants fields event declarations constructor and constructor related methods (Initialization stuff etc.) public methods private methods overrides properties event handlers. Luckily I only have myself to please, but it works for me.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Henry Minute wrote:
I lay my code out in the same order all the time,
I do that to... I just wrap my sections into regions :) I just wish that I could force VS to stuff new event handlers into specific region for me instead of me having to do it on my own. I also wish that it would put them at the current cursor location instead of always at the bottom. I could swear that the VB6 editor used to do that.