[rucksack-devel] Abstracting services

Aycan iRiCAN aycan.irican at core.gen.tr
Thu Jun 15 13:26:43 UTC 2006


Hi,

I'm trying design a library of services that uses rucksack as a
persistent store and I want to get your opinions about my problem.

Think of an accounting service that programmers can use it via generic
methods. This is a service for multiple usage, so it needs to gather
some knowledge like where should accounts be stored, by which
mechanism etc. I tried to think the simplest case, a path variable is
sufficent for accounting to work with rucksack.

My first attempt was defining methods so that they get the values via
parameters.

(defclass account () 
  ((username) (password))
  (:metaclass persistent-class))

(defmethod make-account (uname pass rucksack)
  (add-rucksack-root (make-instance 'account ...) rucksack))

(defmethod list-accounts (... rucksack) ...)

So a programmer can be able to use this package as:

(in-package :p1)
(defparameter *db-path* "/tmp/p1")

(defun create-an-account-with-a-form (form)
  (with-rucksack (rs *db-path*)
    (with-transaction ()
      (make-account (un form) (pw form) rs))))

But I want to make more abstraction so that a program that uses this
library doesn't know about internals of accounting package or
persistent store package. I tried to find a better scenario and wrote
the ideal program:

(in-package :p1)
(defparameter *db-path "/tmp/p1")

(defun create-an-account-with-a-form (form)
  (with-accounting *db-path*
      (make-account (un form) (pw form))))

This way is better because persistence and transactions are
transparent to the programmer. But wait, to be able to reach this
simplicity, I need to redefine my methods.

(defmethod make-account (uname pass)
  (add-rucksack-root (make-instance 'account ...) xxxx))

But I can't, because these methods needs to know the rucksack instance
that they operate on (above shown with xxxx).

What do you think about this? Is this kind of abstraction possible?

Best Regards.

-- 
Aycan iRiCAN
C0R3 Computer Security Group
http://www.core.gen.tr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/rucksack-devel/attachments/20060615/56ce8088/attachment.sig>


More information about the rucksack-devel mailing list