Modeling Object Versions

I am trying to simulate some of our objects in our domain and have encountered the problem that some of these objects may be versioned. Those. the user can create new versions of objects within a certain period of time. So, I need to simulate them in a program. I think this is a common problem in software design.

At first, I jumped to the idea of ​​imitating the concepts of source code version control and proposed the concept and methods of a versioned object, such as registration, verification, etc. But I feel that this is not entirely “systematic” as I did. investigate patterns (i.e. I feel that I am committing sins as

  • I did not cover aspects such as finding more than one solution.
  • studying literature that would give me more reliable links, etc.).

So, my current problem is that for systematic modeling, I need to look for patterns that solve the problem of versioning, preferably in the literature. And take the best of it, of course.

So, I googled for such templates and found only the Temporal Object template. But I was not sure if this was really what I wanted. Do you guys have any suggestions on such schemes?

[Self-Edit] Maybe I did not describe the problem well. You may see a problem similar to the version control problem of the version control file. I have several types of objects (stored in a database) that can have several versions. Inside my application, I have to process all these versions, and I also have to create new versions of objects (which will ultimately be stored in the database). I look forward to some cited template with which I can model the interfaces for accessing / modifying / adding new versions for these objects. The basic interface I could come up with is IVersionedObject with methods like checkout, checkin, undoCheckout, etc. But this is my own idea of ​​monitoring version control systems. I do not think this is a SW design pattern per se. So, we are waiting for a few well-documented design patterns for the above problem.

+7
source share
1 answer

Isn't something like a custom DataMapper working?

doc = DocCatalog.get( docid, version ); 

Assuming that each object can consider the materialization of what the object represents at the given moment (in time). Instead of being an object with the version property, version control takes care of datamapper / catalog / database; those. the object does not know about versions, but the object storage system does.

Saving / saving an object in datamapper will create a new version:

 // saves doc again after changing the title (which indeed stores a new version of it) doc.setTitle ( newTitle ); DocCatalog.save( doc ); // gets a number indicating how many versions of the document exist i_versions = DocCatalog.getVersions( docid ); // returns second-last version of the document doc = DocCatalog.get( docid, i_versions-1 ); 
+1
source

Source: https://habr.com/ru/post/908889/


All Articles