Re: Is this possible...

From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 10/19/04


Date: Tue, 19 Oct 2004 14:52:08 GMT

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:edpE9yStEHA.3984@TK2MSFTNGP09.phx.gbl...
> Thanks, Peter. I think you are right....exceptions might be the way to
go.
>
> "Peter Rilling" <peter@nospam.rilling.net> wrote in message
> news:%23KWBdwStEHA.2536@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:ukbFpsStEHA.2864@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!!
> >>
> >>
> >
> >
>
>



Relevant Pages

  • Re: abstract vs. final
    ... The class only contains static methods - hence there is no reason ... public void testMyMethod() throws Throwable { ... Rather, consider this a scenario that should qualify as an exception from the general rule: being verbose is redundant, and henders the readability of the test's parameters and expected results. ... understanding of Java, object-oriented programming, and proper ...
    (comp.lang.java.programmer)
  • Re: remoting nested types
    ... Could you post the entire exception stack. ... and could you also translate it;) thanks. ... Teleios Systems Ltd. ... Impossible to call non public or static methods ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: remoting nested types
    ... nelSinkStack sinkStack, IMessage msg, IMessage& replyMsg) ... that's the only thing I can see as the exception stack... ... Impossible to call non public or static methods ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: constructors/static methods and inheritance query
    ... > I'm afraid that Nicholas is entirely correct. ... > Static methods should be the exception, ... the static methods if I just make them into more constructors. ... please provide a small code sample. ...
    (microsoft.public.dotnet.languages.csharp)