Re: Code Behind vs not

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Xepol (Xepol_at_discussions.microsoft.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 05:33:02 -0800


"tshad" wrote:
> If I have a choice between the most efficient and the most readable and
> maintainable - the best way is not necessarily going to be the same.

The best code is both readable and maintainable and balances efficency.
Why? Because truly efficent code in NEVER readable, and NEVER maintainable.

True efficiency comes from breaking rules, and the code is ALWAYS ugly and
you can only maintain the code only if you truely understand it. True
understanding is a result of readability. If you had to read the code to
understand it, and understand the code to read it, you've got a catch22 that
most people will never get past.

Besides which, you are writing code for a stack based machine without
registers which will ultimately be compiled to SOME hardware SOMEWHERE with
or without registers, using SOME sort of optomization. It is impossible to
reach the true ideal of "efficent" code with that many levels of abstraction
in the way.

Shoot for reasonable efficency and make your code both readable and
maintainable, because you ALWAYS end up having to work on code again 3 years
after you though you'd never see it again (or worse, someone else). And
frankly, spending copious amounts of time trying to read code to figure out
what it does and how to modify it without breaking everything is decidedly
inefficent.

That said, inline code is good for single page projects where very simple
operations are being performed (I even have 1 page designed like that, it
contains about 3 lines of code, hardly worth code behind!). However, inline
code is horribly inefficient when dealing with a project that contains more
than 3 pages which interact (and even if you don't think you are making
objects, think again, each page is an object).

I think, however, we need to discuss your use of tools. I believe you
mentioned you were using Dreamweaver. I suspect that you will find that
OTHER tools, such as Visual Studio are significantly more efficent when it
comes to working with ASP.NET pages (you will also find tools from other
vendors such as borland, so you are not restricted just to MS, but even as a
long time delphi programmer, I prefer VS to borland in this arena).
 
If you would like to see how a larger scale project works with code behind,
check out dotnetnuke (www.dotnetnuke.com), and just imagine how unbelievably
hard it would be to manage the project with inline code (esp. since they've
abstracted commonly used code into objects with no associated pages).

Hope that helps.



Relevant Pages

  • Re: Code Behind vs not
    ... maintainability are certainly high priority, ... Because truly efficent code in NEVER readable, ... > understanding is a result of readability. ... > long time delphi programmer, I prefer VS to borland in this arena). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Code Behind vs not
    ... > The best code is both readable and maintainable and balances efficency. ... > understanding is a result of readability. ... There are times where Code-behind isn't necessarily the best way. ... > hard it would be to manage the project with inline code (esp. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Add a ternary operator to the language?
    ... *does* improve readability in the sense that now you can see three more ... Adding a ternary operator proper would be the correct solution, ... and I hope Borland can see fit to add this (assuming it's not a time ... consuming addition). ...
    (borland.public.delphi.non-technical)