Assume that you have a User object, which abstracts an authenticated user of
your application. It has some properties such as UserID, FirstName,
LastName, etc. and a method LogOut(); The LogOut method logs the user out
of the application. If the LogOut() method is successful, the user is
logged out and the User object should no longer be valid. Is there a way to
allow the LogOut() method to force the reference that is being held to the
object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all properties
after the LogOut() method has been successfully executed. But I was just
wondering if it might be possible to actually blow away the object itself.
Thanks!! 5 1163
No, an object cannot set itself to null.
You could return empty values but it might be better to throw an exception.
"craig" <e@mail.com> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl... Assume that you have a User object, which abstracts an authenticated user
of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a way
to allow the LogOut() method to force the reference that is being held to the object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all properties after the LogOut() method has been successfully executed. But I was just wondering if it might be possible to actually blow away the object itself.
Thanks!!
Thanks, Peter. I think you are right....exceptions might be the way to go.
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... No, an object cannot set itself to null.
You could return empty values but it might be better to throw an exception.
"craig" <e@mail.com> wrote in message news:uk**************@TK2MSFTNGP09.phx.gbl... Assume that you have a User object, which abstracts an authenticated user of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a way to allow the LogOut() method to force the reference that is being held to the object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all properties after the LogOut() method has been successfully executed. But I was just wondering if it might be possible to actually blow away the object itself.
Thanks!!
don't throw an exception, instead of calling log out, set it to null anyway.
Then in the finalize method, put the code that has to happen on logout, so
it will be executed anyway.
"craig" <e@mail.com> wrote in message
news:ed**************@TK2MSFTNGP09.phx.gbl... Thanks, Peter. I think you are right....exceptions might be the way to go.
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... No, an object cannot set itself to null.
You could return empty values but it might be better to throw an exception.
"craig" <e@mail.com> wrote in message news:uk**************@TK2MSFTNGP09.phx.gbl... Assume that you have a User object, which abstracts an authenticated user of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a way to allow the LogOut() method to force the reference that is being held to the object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all properties after the LogOut() method has been successfully executed. But I was just wondering if it might be possible to actually blow away the object itself.
Thanks!!
I don't if this will fit in with your existing code,
but you could declare the LogOut method as a static member
of your class and pass the object that is to be logged
out as a ref parameter (doing all that has to be done,
and nulling the parameter at the end).
Willem van Rumpt
craig wrote: Assume that you have a User object, which abstracts an authenticated user of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a way to allow the LogOut() method to force the reference that is being held to the object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all properties after the LogOut() method has been successfully executed. But I was just wondering if it might be possible to actually blow away the object itself.
Thanks!!
One other option is to seperate the data about the user from the class that
manages the authorization (like .NET does).
So, have one class that holds the user id, first name, last name, etc. Have
another with "login" and "logout" static methods and a method
("getuserdata") to return the current user's data object.
Logging in would be a matter of
loginmgr.login(userid, password)
User data would come from
userdata = loginmgr.getuserdata()
Logging out would be
loginmgr.logout()
At this point, calling getuserdata() raises an exception.
Since userdata is readily available from calling the static method, you
wouldn't need to pass it around as an object. Good design will dictate that
the data can stay around only as long as it is needed, and not one second
more.
HTH,
--- Nick
"craig" <e@mail.com> wrote in message
news:ed**************@TK2MSFTNGP09.phx.gbl... Thanks, Peter. I think you are right....exceptions might be the way to
go. "Peter Rilling" <pe***@nospam.rilling.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... No, an object cannot set itself to null.
You could return empty values but it might be better to throw an exception.
"craig" <e@mail.com> wrote in message news:uk**************@TK2MSFTNGP09.phx.gbl... Assume that you have a User object, which abstracts an authenticated
user of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a
way to allow the LogOut() method to force the reference that is being held to the object to which it is a member (User) to be set to null?
If not, I can force the object to return empty values for all
properties after the LogOut() method has been successfully executed. But I was
just wondering if it might be possible to actually blow away the object itself.
Thanks!!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Julia Briggs |
last post by:
I am struggling to create a PHP function that would take a specified
image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail
so it will always fit in a 200x250 space. I am hoping...
|
by: rbt |
last post by:
Say I have a list that has 3 letters in it:
I want to print all the possible 4 digit combinations of those 3
letters:
4^3 = 64
aaaa
|
by: CHIN |
last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i
cant find the solution !! )
I have to upload a file to an external site, so, i made a .vbs file , that
logins to...
|
by: Andrzej |
last post by:
Is it possible to call a function which name is given by a string?
Let assume that I created a program which call some functions for example
void f1(void),
void f2(void),
void f3(void).
...
|
by: Bhupesh Naik |
last post by:
This is a query regarding my problem to make a spell and
grammar check possible in text area of a web page.
We have aspx pages which are used to construct letters.
The browser based screens...
| |
by: AAA |
last post by:
hi,
I'll explain fastly the program that i'm doing..
the computer asks me to enter the cardinal of a set X ( called "dimX"
type integer)where X is a table of one dimension
and then to fill it...
|
by: Piotr Nowak |
last post by:
Hi,
Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.
I do not want to refresh my page i.e....
|
by: RSH |
last post by:
Okay my math skills aren't waht they used to be...
With that being said what Im trying to do is create a matrix that given x
number of columns, and y number of possible values i want to generate...
|
by: Robert S. |
last post by:
Searching some time now for documents on this but still did not find
anything about it:
Is it possible to replace the entry screen of MS Office Access 2007 -
that one presenting that default...
|
by: bjorklund.emil |
last post by:
Hello pythonistas.
I'm a newbie to pretty much both programming and Python. I have a task
that involves writing a test script for every possible combination of
preference settings for a software...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |