Tuesday, October 6, 2009

Tech: ASP.Net annoys me sometimes

I apologize... this post is going to be pretty computer programming centric. For those of you who read this post, and who don't know me personally, I am a software engineer. My job is primarily done with WinForms and C#.Net. But there are projects that lean toward my roots which is web technology. Right now I'm working on a web application that I shouldn't say too much about, but which has become a source of frustration.

How? Well... it's written with ASP.Net.

Prior to ASP.Net, if you wanted to stick with microsoft technology, and you wanted a highly interactive webpage, you used HTML (basis of all web pages), ASP, and Javascript. Each piece handled it's own area of expertise. HTML was the set of tags that told the browser what to show and how to show it. Javascript was the client side script code to handle things like field validation and to update stuff on the page without having to make a request on the network to the server for more info. ASP handled the server side stuff including talking to databases and so forth.

ASP.Net though... they seem to be trying to take responsibility for all the roles the other things used to take. Now, ASP.Net is trying to write all that other code for you. You have drag and drop components that try to do things for you, but in the process they limit your ability to use the other tools effectively. And on top of that, it's not even efficient code. So it does make some things easy, but it murders your web site performance, and limits your ability to do what you need to do in some cases.

An example: ASP.Net provides an "update panel" that is supposed to leverage Ajax technology so you can update sections of your webpage without doing a full page request from the server. The idea is that if you ask the server for small bits of information and just change the page the user already sees, you can improve performance since the computers and network do less. It's a great idea, and the ASP.Net Update Panel does make it easy to implement... you don't have to write any Ajax code or even know what it is. But it's such a crappy chunk of code. It doesn't give you the performance benefits because in the background... it's STILL DOING THE FULL PAGE SUBMIT. You aren't passing just a small chunk of information to the server... It's like using a nuke when all you needed was a bullet, and yes... the nuke in this analogy still destroys everything around it despite only wanted to shoot one target. It's annoying.

Fortunately, you can just write your own Ajax code, and have it work fine.

What I'm dealing today, and probably for the next few days, is figuring out why ASP.Net won't let me use javascript to update some form fields and still get the data to the server side so I can store it in the database. It's as though if you don't use the officially sanctioned ASP.Net method to accomplish something, it won't let you do it. Which is horrendously stupid, and massively offensive that microsoft would code it that way. I can only imagine ASP.Net is aimed at people who don't know much about web code, and aren't looking to do anything complicated... where "complicated" really means: "things microsoft didn't anticipate". And honestly, I can do most of the things ASP.Net controls do, but better.

So why did I use ASP.Net in the first place?

I didn't. I wasn't in charge of this project at its inception. And the guy who was is a back end programmer. Doesn't even like working in winforms UI... Prefers the business logic layer and the database. And he's damn good at it. But he got tricked when he got hired here and got through into a UI intensive web application project. And with ASP.Net, he successfully built the app. The problem is that as the app grows, and since he left the company, ASP.Net is no longer capable of giving us what we need. And I'm stuck on this stupid bug that doesn't seem to have a solution.

So I guess this post is about venting. Maybe it's also a warning. Web programmers using a microsoft base (which is fine. I like ASP... just not ASP.Net), should strongly consider using basic ASP, and writing their own controls. Don't use master pages. Don't use the built in ASP.Net controls (a "label" is just a span... you can write a span can't you?). Don't use repeaters (If I believed in a god I'd say "for the love of God don't use repeaters").

You'll end up with a far better application that is far better capable of dealing with new needs down the line.

No comments: