View Single Post
Old July 19th, 2007, 09:11 AM
planoie's Avatar
planoie planoie is offline
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

I'm not sure how to explain this concept differently than I have. Maybe I can use this analogy:

When I buy a plane ticket I purchase it online. I go to the airport ticket counter and present my ID to the agent who finds my reservation to verify my right to board the plane. She prints me out a ticket. Now I move on to security. They ask for my ticket to verify that I can enter the secure part of the airport. Then I go to the boarding gate. Before I can board the plane I show my ticket again to the gate agent. Then I get on the plane.

In this analogy, I have "login" credentials (my name, maybe a reservation number). The agent verifies that and issues me a printed plane ticket, which I hold. This is like creating a user class instance with the user information in your application. As I move around the different parts of the airport I present my ticket as my authorization to be there. Similarly, as you launch forms of your application, you pass into them (through the constructor) the instance of the user class containing the user's info (ID code, type, etc). The form code uses that information instead of having to check/verify the user's initial credentials.

As far as having two classes holding user data goes. I think I get what you mean with that question. If you want to have a full user class (that presumably would closely mirror the data in the database) as well as a smaller version that would be used as the credentials class, that is up to you. I see no reason not to just use the full user class, that would simplify matters. Of course, you could also make a base class that has the basic information you need to carry around the application and extend that for the full user class that maps to the database.