comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@NoSPAM.cogeco.ca>
Subject: Re: APQ (Connection Cloning)
Date: Thu, 23 Dec 2004 12:04:02 -0500
Date: 2004-12-23T12:04:02-05:00	[thread overview]
Message-ID: <1TCyd.29237$GK5.1510003@news20.bellglobal.com> (raw)
In-Reply-To: <sa4sm5zmds2.fsf@snoopy.apana.org.au>

Brian May wrote:
>>>>>>"Dmitry" == Dmitry A Kazakov <mailbox@dmitry-kazakov.de> writes:
...
> Can somebody please let me know what applications a cloning function
> has? I frequently hear of such functions, but rarely (if ever) needed
> to use one.

The "cloning" calls are for the most part, convenience calls. You can
accomplish the same thing without them, though it is IMHO very inconvenient
and perhaps error prone (because different databases require different
parameters). But if a programmer must do something often enough, then
I believe that the "package" should make it easier and less error
prone for the application writer.

One problem that APQ's API has, is that I rolled the "environment"
into the Connection_Type object (this was discussed earlier). The consequence
of that is that when you need a second database connection (more on that
later), without a clone call, you need to supply all of the same database
connection parameters to create a new connection (userid, password, port
etc.) This is even more painful when you are trying to implement
database portable code, because then you also must concern yourself
with which parameters that must be carried over.

For this reason, it makes sense for APQ to 'care' about this, because
it has intimate knowledge of what has been used for the connection.
So cloning a connection becomes easier for APQ to do, than it would
be for the application writer to do it, without APQ's help.
The programmer simply wants another connection "like that one".

Why a second database connection? The reasons vary, but the following
reasons come to mind right away:

  - If you are maintaining a pool of connections to the same database
    (webserver). Even if you start with a fixed set of connections,
    a server may want to add to the pool as demand increases.

  - Client library limitations: most operations can share the same
    connection, but there are probably some cases where this cannot
    be done (I believe for example, you can only have one active
    transaction going on one connection).

  - You may want to restrict trace (debug) SQL operations, when
    debugging a difficult problem. To reduce the amount of trace
    capture, a cloned connection without tracing may be useful.
    In this case, you would revert back to a single connection
    once the debugging was successfully completed.

This "need" would largely disappear if the database userid, password
etc. was taken out of the Connection_Type and put into a 3rd
object Environment_Type instead. I know Dimitry disagrees with the
yet another object approach, but I believe this is the right
thing to do (TM). In his favour however, I do like the internal
smart pointer idea, to guarantee that essential objects
(connection and environment) do not go out of scope prematurely.

Once the connection "parameters" were placed into their own
Environment_Type object, then multiple Connection_Type objects
can be supplied with a common Environment_Type object instead,
and no "cloning" primitives would be required.

Some of the earlier discussion around internal smart pointers
to these objects starts to make a stronger case as you add yet
another object to the mix. Internally, the Connection_Type object
should hold a smart pointer back to the Environment_Object, and
of course, Query_Type objects would hold a smart pointer back
to the Connection_Type object. Then as has been suggested, you
could drop the Connection_Type object argument in some of the
calls like Execute() et al. The following shows how the objects
are related:

  Environment <- Connection <- Query
      1       <-     N
                     1      <-   N

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg



  parent reply	other threads:[~2004-12-23 17:04 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-15 23:31 APQ Brian May
2004-12-16 11:34 ` APQ Warren W. Gay VE3WWG
2004-12-16 23:58   ` APQ Randy Brukardt
2004-12-17  3:45     ` APQ Brian May
2004-12-17  4:03       ` APQ Warren W. Gay VE3WWG
2004-12-17  4:38         ` APQ Brian May
2004-12-17  9:06           ` APQ Egil H. H�vik
2004-12-17 11:42             ` APQ Brian May
2004-12-17 22:55               ` APQ Brian May
2004-12-18 15:52                 ` APQ Warren W. Gay VE3WWG
2004-12-18 18:23                   ` APQ Dmitry A. Kazakov
2004-12-21 23:34                     ` APQ Brian May
2004-12-22  8:57                       ` APQ Dmitry A. Kazakov
2004-12-22 10:07                   ` APQ Martin Krischik
2004-12-22 13:15                     ` APQ Dmitry A. Kazakov
2004-12-22 16:53                       ` APQ Martin Krischik
2004-12-22 17:21                         ` APQ Dmitry A. Kazakov
2004-12-22 18:23                           ` APQ Martin Krischik
2004-12-17  8:59       ` APQ Stephen Leake
2004-12-17 14:12       ` APQ Dmitry A. Kazakov
2004-12-17 23:20         ` APQ Brian May
2004-12-18 16:13           ` APQ Dmitry A. Kazakov
2004-12-21 23:29         ` APQ Brian May
2004-12-22  9:14           ` APQ Dmitry A. Kazakov
2005-01-04 21:32             ` APQ Brian May
2005-01-05 11:58               ` APQ Dmitry A. Kazakov
2004-12-23 17:04           ` Warren W. Gay VE3WWG [this message]
2004-12-23 17:55             ` APQ (Connection Cloning) Georg Bauhaus
2004-12-23 18:52               ` Warren W. Gay VE3WWG
2005-01-03  7:40                 ` Frank Piron
2004-12-17 13:54 ` APQ Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox