Strategies for getting an object on server side.

There's a lot of -Project- objects stored in some collection on server.

The GUI uses the server facade to perform services.

There're several Frames and each one related to one server -Project- object.

Performing any operation on server from any GUI Frame would be calling methods like these:

methodOne(String projectName, params...)

methodTwo(String projectName, params...)

methodThree(String projectName, params...)

methodNNN(String projectName, params...)

Under this point of view I'd have to pass always the projectName to any service on server so it knows what Project to retrieve and follow the algorithm...

It's horrible.

I analized about doing a Proxy that returns the facade but previously to returning it, setting the ProjectName to some variables like "activeObject". This variables would be declared inside the Facade.

The third alternative would be setting the prjName facade variable by each Frame ( setting it to the facade ) when it gains the focus.

But this way the facade would have to present a method like

setActiveProject(String prjName)

Hear other suggestions or best of those.

Regards.

[1208 byte] By [jfreebsda] at [2007-11-26 22:08:23]
# 1

Instead of sending a String object with the name of the project, and then sending 'params', you could:

create a type to hold the 'params' and send an object of that type. When you create the type you could include a variable that will hold an id number for the project. Something like:

public class Params {

private int id= // project id goes here

private int param1=

private int param2=

The method call from the GUI frame would look like

methodT(Params p)

methodR(Params p)

method8(Params p)

methodNNN(Params p)

GhostRadioTwoa at 2007-7-10 10:54:25 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
The essence of the facade is to publish its services expecting the types that really defines each service and maybe not create a Param type wrapping the real parameters that the facade would excepts.
jfreebsda at 2007-7-10 10:54:25 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
Maybe the facade could be kept intact with methods recieving types like Int, String, etc. but add a method execute(Cmd) that implement the cmd pattern that where every parameter is wrapped inside this Cmd object and finally this Cmd knows what method to call in the facade =S
jfreebsda at 2007-7-10 10:54:25 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

There is nothing horrible about it.Sure you can create a facade to hide this fact if there is some benefit to hiding it on some level. However, in no way is this to be considered horrible.

I use RMI though and instead of passing the project name each time, its kind of like the setActiveProject method. I have a project class that I make calls on. So I don't expose each method to take a project name, I expose the project itself. and the methods are on the project class.

_dnoyeBa at 2007-7-10 10:54:25 > top of Java-index,Other Topics,Patterns & OO Design...