Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: bob@brasko.net
Cc: eliz@gnu.org, gdb-patches@sources.redhat.com
Subject: Re: RFC: MI output during program execution
Date: Fri, 12 Aug 2005 20:54:00 -0000	[thread overview]
Message-ID: <200508122051.j7CKpquT005196@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <20050812203052.GA11539@white> (message from Bob Rossi on Fri, 12 Aug 2005 16:30:52 -0400)

> Date: Fri, 12 Aug 2005 16:30:52 -0400
> From: Bob Rossi <bob@brasko.net>
> 
> On Fri, Aug 12, 2005 at 08:13:17PM +0300, Eli Zaretskii wrote:
> > > Date: Fri, 12 Aug 2005 07:49:29 -0400
> > > From: Bob Rossi <bob@brasko.net>
> > > Cc: gdb-patches@sources.redhat.com
> > > 
> > > On Fri, Aug 12, 2005 at 12:43:19PM +0300, Eli Zaretskii wrote:
> > > > > Date: Thu, 11 Aug 2005 21:28:10 -0400
> > > > > From: Bob Rossi <bob@brasko.net>
> > > > > Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com
> > > > > 
> > > > > Thanks for all the guidence so far. Even though you have not attempted
> > > > > the observer approach, how do you feel about it? Is this something that
> > > > > you think could be accomplished with the current FSF GDB? Nick, Daniel
> > > > > and Eli, do you like this approach?
> > > > 
> > > > The record will show that I dislike using observers in core GDB
> > > > sources (i.e. in the sources released with official GDB
> > > > distributions).  But my opinions on this are usually voted down.
> > > 
> > > I would like to become more educated on the pros/cons of the two possible
> > > approaches in solving this problem. What do you not like about the
> > > observer approach that the hook approach solves better?
> > 
> > I'm not sure what you mean by ``the hook approach''.  From my point of
> > view, observers are simply one implementation of the hook approach.
> 
> Yes, as I was thinking about this later, I realized that this was true.
> However, I was thinking the the "hook approach=>jim's implementation",
> was simply an implementation of the observer design pattern. The
> observer pattern can be defined as,
> 
>    Define a one-to-many relationship between objects so that when one
>    object changes state, all its dependents are notified and updated
>    automatically.
> 
> Obviously, there is a 1-1 relationship between the FE and GDB, but I
> don't think that should be a big deal.

It is a big deal.  Problems with an essential one-to-one relationship
don't need the complication of an implementation designed for
one-to-many relations.  There the observer pattern doesn't make any
sense.  On the other hand, if a relationship is one-to-many but just
happens to be one-to-one because there is only one of many finished
implementations, the observer pattern makes sense.

> > I dislike using observers because, in a C program, that looks
> > suspiciously like the coder doesn't know what the program is doing.  C
> > is not a polymorphic language, so in a C program events happen and
> > data of certain type arrives via a 100% predictable and deterministic
> > path.  If you know where the event happens which you want to hook,
> > simply arrange for your function to be called directly by whatever
> > generates or receives that event.
> 
> OK, this seems reasonable. One thing to note is that the FE may be in C++
> or Java, which would lend nicely to the Observer design pattern. CGDB is
> written in C, so this doesn't really matter to me.

Oh come on.  A lot of those "modern" languages are just syntactic
sugar (and in the case of C++ its a full wedding cake that makes you
sick if you eat too much of it).  C programmers have been using the
observer pattern for ages, even before the name observer pattern even
existed.

> > In addition, using observers raises an issue with multiple observers
> > watching the same events and stepping on each other's feet.  In other
> > words, the observer facility doesn't promise anything about the order
> > in which the observers are invoked, and doesn't give us control on the
> > order, so a potential arises for conflicts, if several observers futz
> > with the same data structures or try to produce opposite effects.
>

This is the real reason to be careful with the observer pattern.  If
you encounter interdependencies between observers, the observer
pattern is not the right solution for your problem.

Mark


  parent reply	other threads:[~2005-08-12 20:52 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1123605445.30442.ezmlm@sources.redhat.com>
2005-08-09 17:24 ` Jim Ingham
2005-08-09 17:59   ` Bob Rossi
2005-08-09 18:09     ` Jim Ingham
2005-08-09 18:23       ` Bob Rossi
2005-08-09 18:40         ` Jim Ingham
2005-08-10  0:48           ` Daniel Jacobowitz
2005-08-10  0:48             ` Jim Ingham
2005-08-10  2:37               ` Daniel Jacobowitz
2005-08-09 18:13   ` Eli Zaretskii
2005-08-09 18:23     ` Bob Rossi
2005-08-09 19:39       ` Eli Zaretskii
2005-08-10  0:41         ` Bob Rossi
2005-08-10  0:42           ` Daniel Jacobowitz
2005-08-10  1:07             ` Bob Rossi
2005-08-10  2:37               ` Jim Ingham
2005-08-12  8:06                 ` Bob Rossi
2005-08-12 10:36                   ` Eli Zaretskii
2005-08-12 12:05                     ` Bob Rossi
2005-08-12 17:25                       ` Eli Zaretskii
2005-08-12 20:45                         ` Bob Rossi
2005-08-12 20:49                           ` Daniel Jacobowitz
2005-08-13  1:11                             ` Bob Rossi
2005-08-13  1:15                               ` Daniel Jacobowitz
2005-08-13 11:07                             ` Eli Zaretskii
2005-08-12 20:54                           ` Mark Kettenis [this message]
2005-08-13 15:05                             ` Bob Rossi
2005-08-12 21:01                         ` Daniel Jacobowitz
2005-08-13 11:13                           ` Eli Zaretskii
2005-08-12 17:03                   ` Jim Ingham
2005-08-13  0:33                     ` Bob Rossi
2005-08-13  0:44                       ` Jim Ingham
2005-08-13  5:04                         ` Bob Rossi
2005-08-13  6:47                           ` Daniel Jacobowitz
2005-08-13 11:06                             ` Jim Ingham
2005-08-13 14:51                               ` Bob Rossi
2005-08-13 16:55                                 ` Daniel Jacobowitz
2005-08-13 12:53                             ` Eli Zaretskii
2005-08-13 21:52                             ` Mark Kettenis
2005-08-13  0:22                   ` Daniel Jacobowitz
2005-08-11 10:10               ` Daniel Jacobowitz
2005-08-18 13:28 Nick Roberts
2005-08-19  0:52 ` Mark Kettenis
  -- strict thread matches above, loose matches on Subject: below --
2005-08-17  3:18 Nick Roberts
     [not found] <1124238360.5670.ezmlm@sources.redhat.com>
2005-08-17  1:10 ` Jim Ingham
2005-08-15  2:15 Nick Roberts
2005-08-15  2:13 Nick Roberts
2005-08-15  4:26 ` Daniel Jacobowitz
2005-08-15 10:03   ` Nick Roberts
2005-08-16  0:04     ` Bob Rossi
2005-08-16  0:33       ` Nick Roberts
2005-08-16  0:43     ` Daniel Jacobowitz
2005-08-16  3:54       ` Bob Rossi
2005-08-08  5:20 Nick Roberts
2005-08-08 13:05 ` Daniel Jacobowitz
2005-08-08 18:23   ` Jim Ingham
2005-08-09 17:32     ` Nick Roberts
2005-08-21 22:09     ` Nick Roberts
2005-08-24  2:20       ` Stan Shebs
2005-08-24 16:59         ` Nick Roberts
2005-08-24 20:15           ` Jim Ingham
2005-08-24 20:48             ` Nick Roberts
2005-08-27 12:09           ` Stan Shebs
2005-09-12  3:20         ` Nick Roberts
2005-09-12  3:40           ` Daniel Jacobowitz
2005-09-19 10:30           ` Nick Roberts
2005-09-19 13:17             ` Daniel Jacobowitz
2005-09-19 22:12               ` Nick Roberts
2005-09-19 22:17               ` Nick Roberts
2005-09-19 22:32                 ` Daniel Jacobowitz
2005-10-03  3:20             ` Nick Roberts
2005-10-03 13:18               ` Daniel Jacobowitz
2005-10-03 20:28                 ` Nick Roberts
2005-10-03 20:31                   ` Daniel Jacobowitz
2005-10-03 21:39                     ` Stan Shebs
2005-10-03 21:50                       ` Jim Ingham
2005-10-03 21:59                         ` Daniel Jacobowitz
2005-10-03 22:01                       ` Daniel Jacobowitz
2006-03-28  0:40                 ` Nick Roberts
2006-03-28 22:12                   ` Daniel Jacobowitz
2006-03-28 22:36                     ` Nick Roberts
2006-03-28 23:13                       ` Daniel Jacobowitz
2005-08-08 21:00 ` Eli Zaretskii
2005-08-09 17:52   ` Nick Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200508122051.j7CKpquT005196@elgar.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=bob@brasko.net \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox