On 10 May '08, at 7:29 PM, Western Botanicals wrote:
The reason for using the singleton method was to ensure that I never have more than one cache or database access object. Having more than one cache or database access object could lead to having the same data pulled from the database into more than one object.
What if you later find you need to connect to two databases? This actually happened to me in a project. Originally I had made the DB object a singleton, but then later it turned out we had to be able to migrate data from an older database, which meant being able to open a second DB object on that database to read the data out of it, so I had to change a bunch of code around.
Or what if you need to have two semi-independent engines in the same process that each work on the same database, but in different sessions / transactions? This can happen too, e.g. in a web server handling concurrent requests*.
—Jens* This really happens, and can have major repercussions. Ruby doesn't work well inside Apache because, in part, the interpreter has global state so it can't be instantiated multiple times in a sort of mod_ruby. This in turn makes it nearly impossible to run Rails well in a shared-hosting environment where you can't run your own server process.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]