Tags vs. code-behind

  • Thread starter Thread starter Zeba
  • Start date Start date
Z

Zeba

Hi guys..

I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?

Thanks !
 
Hi guys..

I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?

Using code-behind you separate Business Logic and UI design

Using code-inline the script can be changed without re-deploying the
whole application.

http://www.eggheadcafe.com/articles/20030518.asp
 
Using code-inline the script can be changed without re-deploying the
whole application.

Something that should be totally avoided in "true MVC" applications.
It's a bad practice.

Looking into the article, which reads "There are certain situations where a
purely inline - code implementation is justified"... I tend to disagree.

Also, the author does not give any concrete examply to substantiate the
statement.

In my view, inline code can be and must be totally avoided. The reason is
obvious - seggregation of the UI from the logic.... the heart of MVC
pattern.


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
Something that should be totally avoided in "true MVC" applications.
It's a bad practice.

I agree.
In my view, inline code can be and must be totally avoided. The reason is
obvious - seggregation of the UI from the logic.... the heart of MVC
pattern.

I would agree, apart from in one specific instance related to ASP.NET -
Global.asax, where there are sometimes justifications for in-line code...
Juan is a particular advocate of this, IIRC...
 
No disadvantage. MS is moving towards "code free" development.

You can expect to see a lot more of this in the future, so you may want to get into it now.
 
The base argument is really:

Rapid Code Development VS Good Code Development.

Unless I'm whipping up a demo that needs to be done by yesterday,
I would avoid tags 99.9% of the time.

Rapid <> Good most of the time.

Good development means it is maintainable (among other things), and the
<tags> approach is cumbersome in that regard.
 
Hi guys..

I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?

Thanks !

I agree with the other posters wholeheartedly. The UI should most
definitely be separated from the business logic. In my personal
experience, even for fast demos, there's no *compelling* reason to
embed the source code right in the Web page. That assumes, of course,
that you're using Visual Studio or a similar editor that's capable of
handling code-behind files. The plumbing is all handled for you, and
the development experience is virtually seamless.

However, that's my *personal* experience, and your mileage may vary.

Another consideration is whether or not you want people to see your
intellectual property. If the source code is embedded right in the
pages, it's a lot harder to protect your source code from casual
viewing. With code-behind, you can compile the business logic into one
or more DLLs and avoid deploying the .VB & .resx files altogether;
that, coupled with a decent obfuscator, helps to protect your
intellectual property.

Mike
 
Hi guys..

I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?

Thanks !

I would *especially* use a code-behind for data access. You'd be
divulging details about how you connect to your data source. Big no
no.

Same goes for user authentication and authorization.

Call me paranoid. These days, a determined hacker WILL penetrate your
system if he chooses to do so, and if your code is sitting there with
the instructions for connecting to your database right in the Web
pages, you WILL live to regret it.

Be safe. Move the code into a codebehind file. Obfuscate the code
during the build. Then, prior to deployment, remove any and all source
code files (except the global.asax file). Be sure not to include any
sensitive instructions in the global.asax file. Security is
everything.

Mike
 
Back
Top