The code uses modules because it (the code) needs to be able to refer to
the data stored in the module, as well as classes by name. Even if you
used constants, you'd run into the same (possibly more problematic)
problem.
Example:
MyApp.repository.store_data("user", myuserobject);
Obviously, if you have 2 copies of the same program, you don't want them
storing the data in the same location. Using an object and passing it to
each object is also cumbersome.
I think a singleton is the correct pattern to use here, it's just that the
notion of running the same program (with different data) concurrently is
the problem. The ultimate goal is to not have to run 10 copies of pike,
but 1 pike process with 10 threads each running a copy of the program.
Bill
> why use a module and not normal objects?
> seems to me that in this case a singleton is not the right choice...
>
> greetings, martin.
|