May 7, 2010 at 2:26 AM
Edited May 7, 2010 at 2: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
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
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.