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.
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.
-
Don't get me wrong :) I'm a big fan of the Linq. It works really well in my front end. But the performance penalty became very clear after i started to write my calculation program, which basically processes all the information in the database and writes the output to 3 or 4 tables. Currently it runs for 6 to 7 minutes with less input than some of our clients will supply it with in 5 minutes of usage :suss:
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 -
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.
Yes. Actually I only use regions in code that I intend to publish here, in an attempt to assist the reader. They have no affect when I'm writing code in Edit.
-
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
Why? Seriously, a long class is a strong indication of a sub-optimal design. if you design with the Single Responsibility Principle[^] in mind you will find that long classes tend not to occur in the first place!
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"