views:

58

answers:

3

I have a special kind of collection (in an object-oriented programming language) that provides a large range of persistence services, but that is also queried by other components. At times I have objects that I need to store in the repository, but whose type I would like masked from other services until it is ready (e.g., approved, or completed or what-have-you). I solve this by encapsulating the target object in an opaque 'container' class.

As a concrete analogy, you might consider something like a directory in a file system. Lets say that the file-system contains all sorts of photos for a photo-album viewer. There might be some photos that aren't yet ready for publication, but that you'd like managed by the filesystem. They could be hidden from the photo-album by changing the extension (i.e., .jpg.temp instead of .jpg) or by hiding them in an opaque container object (i.e., storing it in a zip or gzipping it), while still taking advantage of the container and the ability of other tools to query all .jpg.temp files.

I'm just looking for standard terminology that might describe such a situation. The Facade and Proxy seems to match the general implementation, but not the intent.

A: 

I think that the state pattern might be the closest that I know of.

Warren
+1  A: 

I think this is a Proxy. It's not a Facade, facade is intended to offer a different interface (often simplified) to an existing interface(s). In your case the interface stays the same, at least that's how I understood your description (maybe some sort of a pseudocode example would be useful to make it clearer).

Igor Brejc
+1  A: 

Igor is right -- definitely a proxy.

It's somewhere between a "protection proxy" and a "virtual proxy".

You're creating a stand-in for the not-quite-ready object, controlling access to it.

A true virtual proxy would create the underlying resource when any operations are requested.

A protection proxy controls what can access the underlying object.

I'd say what you're doing is a little closer to a protection proxy, but protection proxy usually implies authorization/authentication.

Scott Stanchfield