Very disappointing

May 6, 2010 at 12:43 AM
Guys, Have a look on any ASP.NET MVC tutorials include for newbies. Why with ASP.NET MVC tutorials all code use best practices, patterns and extensible, but for ASP.NET Web Forms most tutorials looks like this. Why not to use Repository pattern for data layer ? This will not bring complexity. Why implement all business logic in page code behind controls events but not to move it in to service layer? The scary thing is that tutorial will be used by newbies like example of "best practices" code, because it was published by Microsoft employer. Let's try to teach beginners to use real best practices on they first steps like Scott Gu doing for example! For now TailspinSpyworks tutorial is a great example of - You should never write a code like this! Thanks
Coordinator
May 6, 2010 at 2:06 PM
Edited May 6, 2010 at 2:10 PM

Well paxer, there are many different approaches to problem solving. Not doing this "you're way" does not invalidate the approach. Please feel free to use or not use the sample.

Since it's open source, rather than complain, why not fork the code and show us how you want things done?

Do you really think it's fair to rate a project 1 star becuase I didn't use the data access pattern that you prefer?

May 6, 2010 at 2:25 PM
Edited May 6, 2010 at 2:27 PM

sorry Joe, but o thought that use some data layer pattern today in 2010 is like a standard.  The beautifull example of best practices i think was done in Nerd Dinner tutorial. I really hoped to see similar approaches for web forms in the tutorial for beginners. I don't think that it will bring complexity but it will definitely  show at least a good direction where to move...

Coordinator
May 6, 2010 at 2:59 PM

The object of .NET's diversity is to NOT force a developer to work the way one person thinks things should be done.

If you read the pdf yyou'll see that the option of a seperate DAL was discussed and defered in th einterest of simplicty.

In an application this size adding a DAL DOES create complexity that will be daunting to some developers since a REAL Data Access Layer requires maeshaling the data from DAL to BAL to UI.

For folks that choose this method MVC is designed for exactly that (which is probably why you refer to liking MVC samples) but this is NOT an MVC sample (and intentionally so).

Not all applications require for do all developers want or need to be constrained by a specific pattern to develop a good application.

As with all samples, if it works for you great, if not, ignore it - bet it seems unfair to stay it stinks because YOU personally would have added a layer of complexity that someone else did not feel was necessary :)

Perhaps you can modify the application to show us how you would have done things your way?

May 6, 2010 at 11:49 PM
Edited May 7, 2010 at 3:33 AM

with all respect Joe, i have no doubt that you and Scott know much more about approaches and patterns then I.  I am just talking that for me this tutorial looks like ... -  for example if in the old good times before OOP languages you wrote a similar tutorial but instead of using function and procedures you decided  to use GOTO just to avoid complexity :) Simplicity is important but it should be reasonable. I also thought that this tutorial was done like Starter Kit, i mean application which could be used to continue developing and extending, that's another reason why i was disappointed about missed data access layer, because most of beginners will not add this layer, they will just continue in the same style like they have now...

I will do modifications and show it here with explanation why i think it's better.

May 7, 2010 at 3:26 AM
Edited May 7, 2010 at 3:45 AM

Ok, like i said i've done some modifications in the source which is think makes this code better.

1) I replaced all logic from all controls events methods eg Page_Event(),  btnSubmit_OnClick() etc to separate methods. I've done this becouse we could have a several methods which should be fired on Page_Load for example, and if we will implement all logic in one place this will make code unreadable later.

2) I removed as i think unnecessary try catch blocks, i think that try catch should be used only in the real not predictable situations, for example exactly in the moment of writing to database as we don't know does Sql server up or down, or sending emails as we can't be sure does SMTP works or not. In other cases as i think we need to avoid using try catch and try to handle possible errors manually, as this will bring a big problems when application become big and we need to debug it and find some error.

2) I implemented repository pattern for data access layer and an interface for it. Later someday we can start using IoC framework to make code less coupled, but for now for this first simple version for beginners it's enough. I think that one more class and abstraction layer does not make application not subtable for beginners, but it will show them at least a good direction. 

Here the source code of the solution

http://dl.dropbox.com/u/4465405/Source.zip

All my thoughts this is not a rules of course,  this is just my thoughts. We can do our job in any way, but let's try together looking for better ways. And let's discuss  and share our thoughts as more as we can especial when we all have one big love to programming and .Net :) And let's double our attention on tutorials as beginners use it like template example for creating own projects.

 

May 7, 2010 at 4:05 PM

Thanks for following up with your positive thoughts and hopes for us beginners, paxer!  I appreciate the code, too.

It is good to get more viewpoints on how to do stuff and also to collaboratively contribute ideas for improvements.

Jim