Restricting access/functionality to objects

K

Karsten Wutzke

Hello!

I have a design question for a restricting access to instances of type
"User" and "Chat" (interfaces).

public interface Chat
{
public String getName();
public void setName(String strName);

public User getOwner();
public void setOwner(User usrOwner);

public List<User> getUserList();

//... which methods? join(User usr), kick(User usr, User
usrKicker), ban(User usr, usrBanner), ...
}


How does restricting work (best)?

1. There's the way of not exposing unwanted functionality via the GUI,
however accessing the model objects can still produce an unwanted
command. Of course, not showing restricted functionality will be done
in any case.

2. The list of commands generated via some CommandFactory (the objects
that would do something when a button gets pressed) is limited by the
user's or some other level. The commands act as messenger objects, but
nevertheless, someone could potentially call the same methods as the
commands do.

3. Somehow provide different implementations of an interface by
subclassing and throwing UnsupportedOperationException for those
operations/method calls that are not allowed with the current user's
level. One could also implement this via several Strategies, one per
method. I'm not sure, if the Bridge pattern could be applied as well.
Disadvantage here would be, that I'd need one subclass per user level
(admin, moderator, owner, operator, normal). In case the user's level
gets upgraded, the instance/s of such chats would have to be replaced.
Looks like bad design.

I'm not quite sure what to do here. I have also created a concrete
subclass of a Chat interface called ChatProxy which is suppoed to
handle the communication with the actual chat server (no
implementation yet). Such a proxy might act as an "access proxy", but
again, I need some more input on this matter designwise.

Another thing:
When using commands (command pattern) objects which work on the
receiver (Chat interface?), would it make sense at all to call methods
on the Chat interface like join(...), kick(...), ban(...) or go to the
server directly and dump those methods on the Chat interface entirely?

Any useful help appreciated!

Karsten
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top