Comp241 Midterm Review

Miscellaneous

The topics listed below were deemed “important to know” for the Comp241 Midterm scheduled for Nov 13, 2008 by Rob Thorndyke.

Session Management

Client-side

  • scalable – each client is storing its own state, you can have 1 or 1,000,000 clients and it’s all the same to the server
  • distribute load to more servers
  • easier to have persistent data
Server-side

  • secure
  • lower bandwidth requirements – state doesnt go back and forth with each request.
  • sharing data between clients (careful though, session data is generally locked to one client)

Those are the advantages/disadvantages.  How do you actually implement these?

Client

  • Cookies
    • persistent
    • can be turned off / modified
  • Query String (BAD, try not ever to use these if you want your site to rank in google)
    • can’t be turned off
    • user sees it, and curious people will change them
    • search engines can’t deal with them very well
    • browsers can limit the max length
    • setting values is not supported in .NET
    • GET only! does not work with POST
  • View State (implemented using hidden fields)
    • nice support in .NET
    • supports POST
    • with ViewState, watch the bandwidth – everything gets sent back and forth
  • Hidden Fields

For all of the above, data must be key/value pairs and must also be serializable.

Server

  • Sessions
    • unique to each client “connection”
    • time out after a while
    • may depend on Cookies (the session id is generally stored in a cookie, this can be turned off but then the session id goes in the query string)
  • Application
    • global – share data between clients
    • web servers can reset these at seemingly random moments

Data Management

Connected Objects

  • DBCommand – SQL Statement
  • DBConnection – interface to the DB
  • DBDataReader
    • read-only
    • forward-only
    • safer
    • faster (lightweight)
  • DBDataAdapter – read/write and bidirectional

Disconnected Objects

  • DataSet
  • DataTable
    • DataTable.Select() – returns DataRow[] (array of DataRow’s)
  • DataRow
    • Field access (read overwrite)
    • Acts as dictionary
int status = (int) ds.Tables["table"].Select("row = 7")[0]["status"];
  • DataColumn
  • Relation

Data-Bound Controls

  • Control.Databind() – Refreshes the view with current DataSource

Input Validation

General Info

  • gives you a chance to check user input and make sure it is valid
  • generally you need to do the validation on BOTH the server and the client
  • server
    • needed in case client validation is bypassed
    • has access to DB -> more complex validation
  • client
    • convenient – quick validation without PostBack

Validation Controls

  • RequiredFieldValidator
    • non-empty / not “default”
  • CompareValidator
    • compare two values (==, <=, >=, …etc)
  • RangeValidator
    • MinimumValue
    • MaximumValue
    • it checks for value between (inclusive)
  • RegularExpressionValidator
  • CustomValidator
    • ClientFunctionName (javascript function)
    • ServerValidate event handler

C# Properties

private int age;
public int Age {
    get { return age; }
    set { age = value; }
}
Bookmark and Share
No Comments

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">