What is the name of this pattern?

At first I called in the ISnapshotService, this is what it does

CountrySnapshot snapshot = snapshotService.CreateSnapshot<Country, CountrySnapshot>(country);

For this to work Country must look like this

public class Country : ISnapshottable<CountrySnapshot>
  public CountrySnapshot CreateSnapshot(ISnapshotService snapshotService) { }

and CountrySnapshot must look like this

public class CountrySnapshot : ISnapshotFor<Country> { }

I used the name "Snapshot" because I initially intended this service to create immutable snapshots of classes for an end-of-period snapshot of a system for accounting purposes. However it has occurred to me that sometimes the result will not be an immutable snapshot, for example a StockLocation might create a StockAudit (which is not a snapshot.)

So, keeping in mind that this will no longer just create snapshots I need to come up with better names for these 3 interfaces.

  1. ISnapshotService
  2. ISnapshottable - Country implements this to indicate it can create a CountrySnapshot
  3. ISnapshotFor - CountrySnapshot implements this to show it is created from a Country

Any suggestion welcome. Thanks


Seems a lot like memento. Snapshot would be a Memento and Snapshottable would be an Originator that's outsourced its saving capabilities to a SnapshotService.

EDIT: Agreed, this is not memento, although the structure is similar. What it could be is a case of either Temporal Object or - what do you know - Snapshot.

This is a factory pattern. see http://en.wikipedia.org/wiki/Factory_method_pattern

I think it is more like a prototype pattern, because it creates new objects based on the state of an existing object.

I have gone for

  1. IPrototypeService
  2. IPrototype
  3. IPrototypedFrom

Need Your Help

mysqli_stmt_prepare returns false from within a function

php function mysqli

I am trying my best to object orientate my login scripts and checks for my website. As such, I have created a function that is called named "attempt_login". This function uses a database connection...

WebFocus - is there a free/open source alternative?

asp.net olap

What is a good free/open source alternative to WebFOCUS?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.