Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Carrying Objects

Reply
Thread Tools

Carrying Objects

 
 
tshad
Guest
Posts: n/a
 
      10-07-2005
I have a User object that has all the information on the object (firstName,
LastName, email, userName, password, address, gender, dob etc).

I want to only carry in a session variable the logon information (firstName,
LastName, email, userName, password).

Is it best to just carry all the information or create a different object
with just a subset of the information?

I am concerned with efficiency and speed here. If I am carrying a lot of
large objects, I assume that would eat more memory and slow down processing.

Thanks,

Tom


 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      10-07-2005
"tshad" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I have a User object that has all the information on the object
> (firstName, LastName, email, userName, password, address, gender, dob
> etc).
>
> I want to only carry in a session variable the logon information
> (firstName, LastName, email, userName, password).
>
> Is it best to just carry all the information or create a different
> object with just a subset of the information?
>
> I am concerned with efficiency and speed here. If I am carrying a lot
> of large objects, I assume that would eat more memory and slow down
> processing.


Considering this object is only storing text information - it's probably
not going to impact your application too much.

But you might want to extend IIdentity instead - this object is attached
to each authenticated session when it gets authentication and it would
be a good place to place additional user properties.

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfsystemsecurityprincipaliidentityclasstopic.as p


--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-07-2005
One solution is to use composition, where one object is composed of another.

pulblic class UserData
{
private string _firstName;
private string _userName;
...
public string FirstName{
get { return _firstName; }
set { _firstName = value;
}
public string UserName{
get { return _userName; }
set { _userName= value;
}
}

public class User
{
private UserData _userData;
private DateTime _dob;
...
public DateTime Dob{
get { return _dob; }
set { _dob = value; }
}
//User is composed of userData, but exposes the properties as though they
are part of it (no one exteranlly needs to know that we are using
composition)
public string FirstName{
get { return userData.FirstName; }
set { _userData.FirstName = value;
}
public string UserName{
get { return userData.UserName; }
set { userData.UserName= value;
}

//get the core data to store in ur session
public UserData CoreData{
get { return _userData;}
}

//create a new user based on the core-data
public User(UserData coreData)
{
_userData = coreData;
}
}



you can then do stuff like:

User user = User.GetUser(1);
Session["CurrentUser"] = user.CodeData;



and then re-create ur user via:


User user =new User((UserData)Session["CurrentUser"]);


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a User object that has all the information on the object (firstName,
>LastName, email, userName, password, address, gender, dob etc).
>
> I want to only carry in a session variable the logon information
> (firstName, LastName, email, userName, password).
>
> Is it best to just carry all the information or create a different object
> with just a subset of the information?
>
> I am concerned with efficiency and speed here. If I am carrying a lot of
> large objects, I assume that would eat more memory and slow down
> processing.
>
> Thanks,
>
> Tom
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      10-07-2005
"Lucas Tam" <(E-Mail Removed)> wrote in message
news:Xns96E8979E6D941nntprogerscom@127.0.0.1...
> "tshad" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
>> I have a User object that has all the information on the object
>> (firstName, LastName, email, userName, password, address, gender, dob
>> etc).
>>
>> I want to only carry in a session variable the logon information
>> (firstName, LastName, email, userName, password).
>>
>> Is it best to just carry all the information or create a different
>> object with just a subset of the information?
>>
>> I am concerned with efficiency and speed here. If I am carrying a lot
>> of large objects, I assume that would eat more memory and slow down
>> processing.

>
> Considering this object is only storing text information - it's probably
> not going to impact your application too much.
>
> But you might want to extend IIdentity instead - this object is attached
> to each authenticated session when it gets authentication and it would
> be a good place to place additional user properties.


That is probably true, but I haven't worked with that yet and is my next
step, but I need to get this working simply first and then add that later.
May be a little more work, but am under a time crunch here.

Thanks,

Tom
>
> http://msdn.microsoft.com/library/de...l=/library/en-
> us/cpref/html/frlrfsystemsecurityprincipaliidentityclasstopic.as p
>
>
> --
> Lucas Tam ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
>
> Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Carrying data for a Datagrid from page to page tshad ASP .Net 5 05-13-2005 05:39 PM
How to configure bgpv4 "carrying label information" capability advertisement in cisco router ? Arun Cisco 0 06-10-2004 05:49 AM
Session State not carrying across assembly boundary JezB ASP .Net 5 05-26-2004 04:21 AM
carrying the user input across pages.. Ani ASP .Net 1 10-28-2003 10:37 PM
carrying the user input across pages.. ani ASP .Net 1 10-28-2003 05:57 PM



Advertisments