You'll find some of my initial thoughts here - http://argouml.tigris.org/servlets/SearchList?list=dev&searchText=modelelementfacade&defaultField=subject&Search=Search
Maybe it's explained better their, maybe not. I'll try again.
My recent example with the wrapped delete flag was a bit of a side
issue as I realised that this same solution would help with the undo
problems. Lets drop that issue for now though.
Basically I would like to see us keep our own ModelElementCache of
model elements behind our model interface. This cache would contain a
map of ModelElementFacades keyed by the actual MDR model element.
Every model interface method that currently returns a model element as
an Object should call the cache to retrieve a ModelElementFacade
instead and return that, not as an Object but as a ModelElementFacade.
So instead of just
return myModelElement;
we
return ModelElementFacade.getInstance().getFacade(myModelElement);
This looks in the cache's hashmap to see if there is already a
ModelElementFacade for the model element. If so it returns that. If
not then it constructs a new ModelElementFacaade wrapping the model
element, adds it to the HahMap and returns that.
Conversley, every model facade method that take a model element as an
Object argument should instead accept a ModelElementFacade argument.
The first thing these methods would do would be to call the
getModelElement() methods of the ModelElementFacade object to get the
actual MDR objects to work upon.
I've attached an example of how I see the buildConnection method of
UmlFactory being modified for this (although I shorten the argument
list for that method).
We could create extensions of ModelElementFacade for specific types
but I think initially we have enough work just to introduce this
lowest level facade.
Regards
Bob.
The undo stuff is not really relevant but it
On 08/01/07, Tom Morris <[EMAIL PROTECTED]> wrote:
I skimmed this and didn't understand it well enough to comment at the time, but it doesn't look like anyone else has commented either and it sounds like something important, so let's see if we can restart the conversation. I agree that passing all ModelElements through the API as opaque objects of type Object is really bad idea since we lose all the power of Java's type checking, but I'm not sure what issue you're trying to address here. The opaque Object style of API is unfortunate, but a design cleanup, while tempting, seems like less important task than many of the others on our plate. Is the main thrust of this proposal to provide a wrapper to hide the machinery of Undo/Undelete? If so, perhaps a better name than ModelElementFacade would be DeletableModelElement or something similar. It could provide methods specific to its function like delete, undelete, isDeleted, deletePermanently or similar types of things. I think lumping getName() in with delete() is going to start us down the road of creating a single huge interface. Perhaps restating the goals for this new interface would help others provide more focused feedback. Tom > -----Original Message----- > From: Bob Tarling [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 20, 2006 8:16 PM > To: [email protected] > Subject: [argouml-dev] ModelElementFacade (again) > > > With talk of JRE5 coming up I thought this would be a good > time to approach the idea of a ModelElementFacade again. > > With all model elements outside of the MDR model subsystem > being refered to as Object we miss out a fair deal of the > readability that comes with JDK5 syntax. > > What I'd like to see is instead of passing and returning > model elements as Objects that we define our own ModelElementFacade > > Somthing like this - > > class ModelElementFacadeImpl implements ModelElementFacade { > /** > * A reference to the MDR model element > */ > private ModelElement modelElement; > > /** > * Our own deleted flag to help with undo > */ > private boolean deleted; > > /** > * Not public so only flyweight factory can access this > */ > ModelElementFacade(ModelElement mdrModelElement) { > modelElement = mdrModelElement; > } > > /** > * Allow the MDR model subsystem only access to the > actual model element > */ > getModelElement() { > return modelElement; > } > > /** > * Allow anyone to use this facade to get the name of the > model element > */ > public String getName() { > return modelElement.getName(); > } > > /** > * Get the deleted property > */ > public boolean isDeleted() { > return deleted; > } > } > > What are peoples thoughts on this in principle? > > What's the best way of getting from where we are now to > returning wrapped model elements? > > Bob. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ModelElementFacade.zargo
Description: Binary data
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
