Inline Code or Code behind
-
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesI like code behind. It is as simple as that. Here's your well or not-so-well documented code... ;P
namespace Monster_Maker__alpha_ { partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.lbHeader = new System.Windows.Forms.Label(); this.clbPartyNumber = new System.Windows.Forms.CheckedListBox(); this.cbPartyLevel = new System.Windows.Forms.ComboBox(); this.lbPartyNumber = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lbHeader // this.lbHeader.Font = new System.Drawing.Font("Mistral", 26F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbHeader.Location = new System.Drawing.Point(310, 0); this.lbHeader.Name = "lbHeader"; this.lbHeader.Size = new System.Drawing.Size(300, 50); this.lbHeader.TabIndex = 0; this.lbHeader.Text = "Monster Maker (alpha)"; // // clbPartyNumber // this.clbPartyNumber.FormattingEnabled = true; this.clbPartyNumber.Items.AddRange(new object[] { "0", "1 to 3", "4 to 6", "7 to 9", "10+"}); this.clbPartyNumber.Location = new System.Drawing.Point(0, 46); this.clbPartyNumber.Name = "clbPartyNumber"; this.clbPartyNumber.Size = new System.Drawing.Size(120, 94); this.clbPartyNumber.TabIndex = 1; // // cbPartyLevel // this.cbPartyLevel.FormattingEnabled = true;
-
My whole criteria is if there is very minimal code place it inline otherwise use code behind. If the code grows refactor it to convert into a code behind model.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -Brian Kernighan
thats great But it seems to me that there is some unique advantage of using inline code for a much bigger web applications. The whole .Net community are doing that in each and every samples, There has to be something very simple and explainable. just a feeling i have since last week.
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
I like code behind. It is as simple as that. Here's your well or not-so-well documented code... ;P
namespace Monster_Maker__alpha_ { partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.lbHeader = new System.Windows.Forms.Label(); this.clbPartyNumber = new System.Windows.Forms.CheckedListBox(); this.cbPartyLevel = new System.Windows.Forms.ComboBox(); this.lbPartyNumber = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lbHeader // this.lbHeader.Font = new System.Drawing.Font("Mistral", 26F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbHeader.Location = new System.Drawing.Point(310, 0); this.lbHeader.Name = "lbHeader"; this.lbHeader.Size = new System.Drawing.Size(300, 50); this.lbHeader.TabIndex = 0; this.lbHeader.Text = "Monster Maker (alpha)"; // // clbPartyNumber // this.clbPartyNumber.FormattingEnabled = true; this.clbPartyNumber.Items.AddRange(new object[] { "0", "1 to 3", "4 to 6", "7 to 9", "10+"}); this.clbPartyNumber.Location = new System.Drawing.Point(0, 46); this.clbPartyNumber.Name = "clbPartyNumber"; this.clbPartyNumber.Size = new System.Drawing.Size(120, 94); this.clbPartyNumber.TabIndex = 1; // // cbPartyLevel // this.cbPartyLevel.FormattingEnabled = true;
well that could be one reason :laugh:
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesProgammers debate the difference while web designers curse the programmers who do inline code. Separating interface and implementation is still a great idea no matter how much contempt .NET has for it. Examples use inline because it's easier to explain that way.
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesInline code if either there is no UI (eg a pass-through page) ot the UI is something like "<%@ Page inherits=...%> (and nothing else), or the only code is a very small snippet that, say, overrides OnLoad and sets a value or two. My rule of thumb: only separate the code and design if there's code and design that needs separating.
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
thats great But it seems to me that there is some unique advantage of using inline code for a much bigger web applications. The whole .Net community are doing that in each and every samples, There has to be something very simple and explainable. just a feeling i have since last week.
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesIn my experience the use of inline code is a combination of laziness, perceived performance improvement and power grabbing. It is easier and the more you use it, the more you force your view of the interface on the designers.
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
thats great But it seems to me that there is some unique advantage of using inline code for a much bigger web applications. The whole .Net community are doing that in each and every samples, There has to be something very simple and explainable. just a feeling i have since last week.
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesQuartz... wrote:
The whole .Net community are doing that in each and every samples
Maybe they are being :baaaa!:? Use the tools as best it makes sense for your particular application, not because everyone else is cutting and pastingdoing it a particular way
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesInline code is an abomination. Code behind is a major reason that ASP.NET is more readable and maintainable than 'classic' ASP.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Chris Losinger wrote:
code behind is better. anyone who disagrees is wrong.
Well i think, that would be a gross generalization, If you do think like that, What do you think is advantage of using code behind rather than inline code other than number of files ? or if we do assume there is some "advantage behind" using inline code , What could that be ?
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesQuartz... wrote:
Well i think, that would be a gross generalization,
Yep, but it's also true.
Quartz... wrote:
What do you think is advantage of using code behind rather than inline code other than number of files ?
How is having more files an advantage ? Seperating HTML from code is essential to being able to do any sort of layout and being able to maintain code.
Quartz... wrote:
or if we do assume there is some "advantage behind" using inline code , What could that be ?
Less confusing for people who don't get OO, perhaps ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minuteswhen i'm using VS i use code-behinds - its cleaner and my source doesn't get published when i'm using Dreamweaver (yeah, i have to sometimes :)) i use inline - i hate using the commandline complier and inline doesn't have to be compiled. as someone else said above - horses for courses nicko
-
Inline code if either there is no UI (eg a pass-through page) ot the UI is something like "<%@ Page inherits=...%> (and nothing else), or the only code is a very small snippet that, say, overrides OnLoad and sets a value or two. My rule of thumb: only separate the code and design if there's code and design that needs separating.
cheers, Chris Maunder
CodeProject.com : C++ MVP
Chris Maunder wrote:
Inline code if either there is no UI (eg a pass-through page) ot the UI is something like "<%@ Page inherits=...%> (and nothing else), or the only code is a very small snippet that, say, overrides OnLoad and sets a value or two.
may be that could be a reason, Because most of the samples, extensively uses user/custom controls even for the master page layout etc so all they have in each of the page is a page with reference to a control. One more advantage i see using this approach is Recompilation When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Inline code is an abomination. Code behind is a major reason that ASP.NET is more readable and maintainable than 'classic' ASP.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
I do agree with you to an extent because i have been using it for last two years, But it does make me feel somewhat baffled why do they do that in all the samples if you download communityserver or starter kits all are totally inline code atleast there should be some reason for such stupidity (if it is one)
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Chris Maunder wrote:
Inline code if either there is no UI (eg a pass-through page) ot the UI is something like "<%@ Page inherits=...%> (and nothing else), or the only code is a very small snippet that, say, overrides OnLoad and sets a value or two.
may be that could be a reason, Because most of the samples, extensively uses user/custom controls even for the master page layout etc so all they have in each of the page is a page with reference to a control. One more advantage i see using this approach is Recompilation When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesQuartz... wrote:
When you use code behind, you have to recompile the whole application
Eh? Don't you have to recompile too when you change the code even using inline coding? The only time you don't need to recompile is if you change the HTML (excluding the ASP.Net controls), AFAIK.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia
-
Chris Maunder wrote:
Inline code if either there is no UI (eg a pass-through page) ot the UI is something like "<%@ Page inherits=...%> (and nothing else), or the only code is a very small snippet that, say, overrides OnLoad and sets a value or two.
may be that could be a reason, Because most of the samples, extensively uses user/custom controls even for the master page layout etc so all they have in each of the page is a page with reference to a control. One more advantage i see using this approach is Recompilation When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesQuartz... wrote:
When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Not in 2.0.
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesOk , i did find out the reason and i must say its revolutionary and ofcourse a refreshing approach and its not just laziness i know a lot of you might not agree but see this, you might rediscover the inline code ADVANTAGES OF INLINE CODE 1. Deploying single web pages to a server without recompiling the entire solution, That is the BEST ADVANTAGE of inline code YES IF YOU USE YOUR COMPLETE project as inline code this is possible 2. Making localized edits to single pages that take effect in real time. 3. A single file that contains both code and markup in one convenient self-contained package and it loads independently without a need of a web.dll We all know you have to compile the whole web.dll if you use the Code behind but , THIS is FAR more easy to Deploy and Maintain DISADVANTAGES OF INLINE CODE 1. Spaghetti code 2. Extremely limited intellisense 3. Crappy debugging There are definetly some great advantage too if it is done properly I think atleast these could be reason for all those online samples to be inline code
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Quartz... wrote:
When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Not in 2.0.
cheers, Chris Maunder
CodeProject.com : C++ MVP
Gee, there're folks still using 1.1?
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
-
Gee, there're folks still using 1.1?
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Jerry Hammond wrote:
Gee, there're folks still using 1.1
That could be a whole new post, though yes i am still using .Net 1.1 and can't find a reason yet to convert to 2.0, With .Net 3.0 on the stack i think i will jump directly to 3.0 :) -- modified at 20:23 Monday 11th September, 2006
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Quartz... wrote:
When you use code behind, you have to recompile the whole application which is not easy when you have multiple developers working on different parts
Not in 2.0.
cheers, Chris Maunder
CodeProject.com : C++ MVP
Chris Maunder wrote:
Not in 2.0
Thats true With Page level pre-compile and Full runtime compilation, deployment has become a breeze in 2.0 but you will be surprised to know that The default in VS 2005 is "code behind" but can be changed to "inline coding" And VS 2005 not only supports single-file development with inline coding, but has also added/enhanced intellisense support for the inline code in single page development
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutes -
Ok this might look like a programming question but its not, its more on the concept, you decide I am wondering is there any advantage for using "Inline Code" to "Code Behind" in ASP.NET. For last few years i have been doing code behind but recently an increasingly degree of online samples (community server/ asp.net starter kits etc) are using inline code ? What is the prime advantage of that ? Microsoft created code behind, but they themselves are not using it ??? :confused: Can you send me a well documented code as soon as possible, wait... don't vote me down , that was a joke
Omit Needless Words - Strunk, William, Jr.
Web based Project Management
Universal DBA | Ajax Rating | ExplorerTree | Globalization in 20 minutesThis evening or tomorrow, i'll probably be writing a small ASPX page with no codebehind, just to add an RSS feed for a DB table. It's... a page of code. Why bother opening two files?
---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums
-
Gee, there're folks still using 1.1?
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Jerry Hammond wrote:
Gee, there're folks still using 1.1?
It seems the insurance industry is 2-4 years behind the times. If it works, why change it? They'll only switch when they find out they need a particular feature not offered by the current version.
Jon Sagara When I grow up, I'm changing my name to Joe Kickass! My Site | My Blog | My Articles