Maybe not really an "architecture" as such, perhaps more of a set of design goals, or statements. For a recent project I came up with the following:
1) Authentication is carried out in Global_AcquireRequestState. Only done once, then a session variable is set
2) All pages inherit from a BasePage class which provides:
- A "DataAccess" object through which all database activity is conducted (see later)
- A "UserSession" object which is used instead of the default "Session" (see later)
- Global catch all exception handling - for unrecoverable errors
3) All database interaction uses NHibernate
4) DataAccess is a class which collates all NHibernate functions, so the application simply calls dataAccess.GetUserList() to return a list of user objects etc...
5) UserSession is a small class which contains typesafe session variables, so rather than Session["someVar"] I can do UserSession.SomeVar - strongly typed, intellisense friendly and less error prone. I dislike HashTables keyed by text strings, I see this as a very unsafe practice.
6) No code or logic whatsoever in the aspx file - all in the code behind
7) HTTP GET on all page deliveries
- HTTP POST back form data, process it, and then Response.Redirect() to the viewing page - prevents “Warning: Page has Expired” messages
- Item Ids are passed in the URL, so bookmarking of pages is possible
8) Button clicks are all handled in event handlers
9) Consts all places in a globally accessible file, static classes used. E.g. Page names are declared in a static class called “Pages” allowing the developer to use the following syntax to redirect to a page: Response.Redirect(Pages.AccountDetails)
Any comments welcome.
No comments:
Post a Comment