Code Monkey home page Code Monkey logo

clobber's Introduction

Explanation

Clobber is an alternative to so-called “object prevalence”, and in particular to cl-prevalence.

Clobber is both simpler, more flexible, and more robust than systems based on object prevalence.

Simplicity

Clobber is simpler because we do not take any snapshots at all. Other systems typically use a combination of transaction logs and snapshots. Clobber uses only a transaction log which is always read into an empty system.

Flexibility

Clobber is more flexible because the system itself does not define the format of a transaction. Client code can save transactions as Lisp lists, as instances of standard-object, or anything else that can be serialized. It is also more flexible because transactions can contain any object that can be serialized, including model objects. With this method, client code does not need to manipulate “manually created pointers” such as social security numbers, account numbers, membership numbers, etc. whenever it needs to execute a transaction. Instead it can use the model objects themselves such as people, accounts, automobiles and whatnot.

Robustness

Clobber is more robust because serialization of instances of (subclasses of) standard-object is not accomplished based on slots. Clobber considers slots to be implementation details. In other object prevalence systems, whenever the model evolves, the serialization might no longer be valid. In contrast, Clobber serializes instances of standard-object as a list of pairs, each one consisting of an initarg and a value. These pairs can be handled by client code in any way it sees fit. They can be handled by an :initarg, by initialize-instance, or they can be ignored. The downside of the Clobber method is that client code must specify these pairs in the form of an initarg and the name of an accessor function to be called to obtain the value used for the initarg. This inconvenience is however relatively minor, especially considering the additional robustness it buys in terms of less sensitivity to changes in the model classes.

Design

At the heart of Clobber is a mechanism for serializing objects that preserves object identity, much like the reader macros #= and ##, except that Clobber detects sharing within the entire transaction log, not only within a single transaction. This mechanism is what makes it possible for client code to put any old object in a transaction, while making sure that sharing is preserved.

Examples

Two examples are included - see files demo.lisp and demo2.lisp

To run demo.lisp -

(ql:quickload :clobber)
(in-package :clobber-demo)
(start "/path/to/new/file")
(do-things-1)
;; inspect the file to see the transaction log

License

Clobber is in the public domain in countries where it is possible to place works in the public domain explicitly. In other countries, we will distribute Clobber according to a license that lets the user do whatever he or she pleases with the code.

Contact

Send comments to [email protected]

A manual might be written one day.

How to use Clobber

  1. If your application objects are instances of (subclasses of) standard-object, use clobber:define-save-info to tell Clobber how to serialize them.
  2. Determine the data structure your application will use to represent each transaction, and how the application will restore state from each transaction.

    e.g. a transaction could be a list whose car is a function and whose cdr is a list of arguments to the function. State can be restored from such a transaction through (lambda (txn) (apply (first txn) (rest txn)))

  3. Use clobber:open-transaction-log to create a transaction log, usually stored in a special variable.
  4. Call clobber:log-transaction whenever you update your application state. You may wish to define a helper function or macro for this.
  5. Close the transaction log using clobber:close-transaction-log.

Reference

define-save-info (type &body save-info)

open-transaction-log (filename function)

log-transaction (transaction transaction-log)

close-transaction-log (transaction-log)

clobber's People

Contributors

robert-strandh avatar contrapunctus-1 avatar phoe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.