Jeff and .NET

The .NET musings of Jeff Putz

Sponsors

News

My Sites

Does ASP.NET v2 allow you to do the "wrong" thing?

A post today from Paul Wilson got me thinking about what the "right" thing to do is in terms of how you organize code in a Web project. One of the replies in particular implied that the allowance to put code right on the page (which you could do before anyway, without Intellisense) reinforces the old script way of doing things. I don't entirely agree.

One of the goals of my book was to teach former script people (like me) that the world object-oriented programming was worth understanding and implementing. In thinking about the things that cause a mental block for developers in transition, clearly Visual Studio's codebehind model was one of the problems. Not only did we expect the developer to think of objects and classes (oh my!) in more of an abstract sense, but we also wanted them to think about a system of files (assemblies, codebehind, pages) that were also spread apart in an unfamiliar way. The truth is, if you fought against VS, you could do things "the old way" anyway, it was just a pain.

Now v2 comes along, and we can comfortably put our code right there in the page. The design of an application can still be bad, just as it was in v1.x. I should know... the first port I did of POP Forums put the crap all over the place with no true reuse of code. It was a nightmare, but familiar ground for someone coming from the ASP.old world.

PHP is huge, and it's not going away. It's easy to learn. ASP.NET, as of v2, is also a lot easier to learn. The simplicity of the physical file layout makes it easier for a beginner to get their head around what's going on. The challenge is to get them to the next level, and this is what I've been telling bloggers, authors and publishers for two years now. I feel like no one is listening. You can't start bantering about design patterns with a transitional developer before they even understand what a class is. One does not go from script person to uber-code monkey. There are interim steps. In a world where we use iterative development every day, you'd think people would get that!

I guess what I really mean is, don't jump out there and say, "You're doing it wrong, stupid!" Tell people, "This is a better way to do it, and this is why."
Posted: Aug 10 2005, 04:06 PM by Jeff | with 6 comment(s)
Filed under:

Comments

karl said:

*cough* SqlDataSource control *cough*
# August 10, 2005 4:35 PM

Paul Wilson said:

I totally agree Jeff that there needs to be a simplified approach, I just question if sometimes things go too far in the name of simplicity. For instance, I have no problem with code in the page itself, and may do that some now myself now that intellisense is there. I also have no problem with a folder based site for those that want this -- I just have a problem with forcing it upon all of us, especially since it IS a step backwards from v1 to us that have relied on project based sites.

To me the bigger problems are that we often end up "teaching" these newbies/scripters the wrong things due to the cool RAD stuff that is being pushed. I agree we need simplicity where it makes sense, as well as some good wizards, but does that mean that we need to introduce bad habits, especially when they end up being the only way at times. Take the abundance of visual properties that all end up being part of the style tag -- couldn't we have just taught them how to use CSS stylesheets instead? And now those "simple" properties have become so dominant that the CSS stylesheets don't even work (or apparently get tested at MS)! Is this what we really should be teaching?

What do you think? By the way, I have a copy of your book, and the table of contents does look really good -- but alas I just haven't found the time to read it to make a review (and I may never do so since its not really relevant to me).
# August 10, 2005 5:40 PM

Danny said:

Jeff,

Man, I'm right there with you on this one. I too ranted about this a couple of years ago: http://blog.dannyboyd.com/archive/2004/01/08/145.aspx. I'd not encountered your book. I'm ordering a copy for review as soon as I hit submit on this comment.

Danny
# August 10, 2005 10:25 PM

Frans Bouma said:

"don't jump out there and say, "You're doing it wrong, stupid!" Tell people, "This is a better way to do it, and this is why.""
That only works if the people you're talking to understand they NEED a better way to do things.

That's the real problem. Similar to data-access stuff and how to do that in your application: it can be done in a lot of different ways.

I think I can fairly say I'm a very skilled programmer. The thing is, I recently learned that I could learn a hell of a lot of stuff still, and it made me understand that my thinking was locked into a mindset which got a life of its own. Not that that was bad, but with newer insights it got way easier to write code more conveniently, which was cleaner, easier to use and a breeze to maintain.

Knowing that, I realize that telling others there is a 'better' way of doing X, or 'you're wrong', is subjective. There's a DIFFERENT way of doing things, which has these X pros and cons. Do the math yourself. That's the approach I've been taking towards data-access and what you should use for some time now and it really works well: people aren't feeling belittled, on the contrary, they feel they've learned something new and understandable, and with that knowledge in their bag, they can make new decisions.

Oh, what it was what I learned recently? micro-design for OO frameworks. Delegation of responsibility, and of that the really important factor: why.
# August 11, 2005 4:14 AM

Frans Bouma said:

I'd like to add, that I always am against the RADification of development platforms for the wrong reasons. There's nothing wrong with RAD, but it is often done in a way which has more negative side effects than alternatives. With the VS.NET approach towards webapplications and for example also towards webservices (my personal gripe) is one of "trust us, leave it to us to do things for you", but doing it in an inflexible way.
You can do RAD in 2 ways:
1) offer a visual wrapper / designer to perform repetitive tasks, but still perform these repetitive tasks
2) offer a visual wrapper which represents the repetitive tasks.

Option 2 is the one VS.NET follows: there is no way to do it differently in your own code in a lot of situations, for example the webservice crap (wsdl thinks every IXmlSerializable implementation is a dataset). While option 1) offers the same thing, but leaves you the choice of doing it yourself as well. A good example of this is ALSO in vs.net, namely the winforms designer.
# August 11, 2005 4:21 AM

Eric Newton said:


In regards to PHP, theres Phalanger, PHP compiling on .NET: http://www.php-compiler.net/

"don't jump out there and say, "You're doing it wrong, stupid!" Tell people, "This is a better way to do it, and this is why.""

Ok, but most of the time "it just works" and people don't care what the "right way" is. They see these poorly implemented examples, cut and paste them, then their codebase is basically examples that have been expanded upon.

Which goes back to a point I made a while back about "proper example" where we dont show examples that use a chain of += for string concatenation, etc etc etc.

Paul is right, and I agree with him, as you do
# August 11, 2005 10:05 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)