does a web developer need to worry about serialization?

Discussion in 'ASP .Net' started by Dica, Jul 3, 2007.

  1. Dica

    Dica Guest

    i understand the concept of serialization of objects, but do i really need
    to worry about this as a web developer? i tend to pass my BED (business
    entity definition) objects between pages by storing in session as in:

    oUser.firstName = 'whatever';
    oUser.lastName = 'whatever_last';
    Session["oUser"] = oUser;
    Response.Redirect 'nextPage.aspx';

    at the end of my web apps life, any data i really needed to persist would be
    saved to sql server. is there any reason i should consider serializing
    things instead of following my normal course? i'm getting ready to take my
    MCTS exam shortly and would like to incorporate everything i've learned into
    my day to day application development, but don't see a practical application
    for serialization.
     
    Dica, Jul 3, 2007
    #1
    1. Advertisements

  2. I am not sure what you saying.

    allow me to quote you...
    "any data I really needed to persist would be saved to sql server."

    Is not it a Serialization?
    Very often in your applications you need to deal with objects that needs to
    be saved completely.
    Like config object for example. So Microsoft came up with easy way to do it
    with XmlSerizalizer.
    But nothing can stop you to write your own sterilizer that would save only
    data you need.


    George.
     
    George Ter-Saakov, Jul 3, 2007
    #2
    1. Advertisements

  3. Dica

    sloan Guest

    sloan, Jul 3, 2007
    #3
  4. Dica

    Aidy Guest

    Your objects need to be serialisable if you are storing the session in SQL
    Server (not in memory which is default), if you store the object in the
    ViewState, or if you send the object via a webservice. Maybe even remoting
    if you use http as transport. If you are doing none of the above you don't
    need to worry about it.
     
    Aidy, Jul 3, 2007
    #4
  5. Dica

    Dica Guest

    yes, i should have clarified what i meant by that better. i wouldn't save
    the state of the object to sql server, but just the values of the object's
    members. for instance:
    sSql = "insert into users(firstName, lastName) values ('" + oUser.firstName
    + "', '" + oUser.lastName + "')";

    i'll then have an overloaded method to recreate the oUsers object and pass
    in the userID, run a sql statement to grab the values for that particular
    user, and re-populate the object's members that way. but perhaps i could
    learn to save the serialized object to sql server directly and recreate the
    object more effeciently that way.

    tks for the reply.
     
    Dica, Jul 3, 2007
    #5
  6. Dica

    sloan Guest

    Then look at my other entry:
    http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!140.entry




     
    sloan, Jul 3, 2007
    #6
  7. Dica

    Dica Guest

    excellent example. tks.
     
    Dica, Jul 3, 2007
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.