Re: Restricting functionality on objects: "remote access proxy" (pattern)
- From: Karsten Wutzke <kwutzke@xxxxxx>
- Date: Wed, 22 Aug 2007 07:50:52 -0700
On 17 Aug., 20:19, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:
Karsten Wutzke <kwut...@xxxxxx> wrote:
Before anyone complains, this is basically a multipost from the
mainstream Java NG's. I couldn't get any/the answers I need, so I must
go to (what is for me) the "OO-design experts group". ;-)
I have a (Java) interface "Chat":
public interface Chat
{
public String getName();
public void setName(String strName); //basically not executable by
everyone
public User getOwner();
public void setOwner(User usrOwner); //basically not executable
by everyone
public List<User> getUserList();
//... which methods?
//join(User usr)
//sendMessage(User usr, Message msg)
//kick(User usr, User usrKicker)
//ban(User usr, usrBanner)
//unban(User usr, usrUnbanner)
//leave(User usr)
//...
}
How do you restrict access for a real chat room on the network by
using the current (or another user's) level/permissions (there are
admins, mods, owners, ops, normal users)?
The question is the result of improperly thinking of the problem space.
Objects should not be sitting dormant waiting for a command to do a
particular task. Objects should know what they need to do, they are only
waiting for the information necessary to do it.
Think of a Printer for example. You don't order it to print, it lives to
print, all you need to do is tell it what to print.
I'm really out of ideas what could be the right way to do it, though
restricting functionality on (dynamic) user levels seems quite common
to me. This is why I hope to get some more insight from you, even if
you only left some comments "you're basically on the right way", "it's
probably better to do this", "forget that"...
Any help is greatly appreciated!
The metaphor I think of while reading your post is the human body,
trying to fight off pathogens while at the same time taking in foreign
matter. Your server seeks external input, is hungry for it, but it needs
to be able to detect valid/appropriate input from invalid input. A
multi-layerd approach would probably be necessary.
At the first layer, the input must be "digested", in converting the raw
data into useful objects, garbage must be detected and discarded, its
source identified and cut off. If you get garbage data from a particular
MAC address, you know not to eat anymore of that address' data.
The next layer would be to examine the data for how common it is. If the
server receives a Ban command from a source that routinely produces
them, then all is probably well. A bunch of Ban commands for an unknown
source is suspect.
Another layer would work independently from the above. It would look for
damage to the data in the system and work to repair that damage. Are the
number of banned users suddenly increasing? This layer would notify you
of the anomaly start unbanning users.
I've never written anything like what you are trying to create so all of
the above may be suspect. In general though, stop thinking of objects as
tools you use to achieve a particular end, and start giving them a
life/purpose of their own.
I'm not sure if we're talking about the same, but my OP was about the
client side of a chat app only. The server is already implemented (IRC
flavor).
Karsten
.
- References:
- Restricting functionality on objects: "remote access proxy" (pattern)
- From: Karsten Wutzke
- Re: Restricting functionality on objects: "remote access proxy" (pattern)
- From: Daniel T.
- Restricting functionality on objects: "remote access proxy" (pattern)
- Prev by Date: Re: Restricting functionality on objects: "remote access proxy" (pattern)
- Next by Date: Re: A Design Problem
- Previous by thread: Re: Restricting functionality on objects: "remote access proxy" (pattern)
- Next by thread: Looking for C++, OOPs Professionals (Bangalore)
- Index(es):