Re: [GnomeMeeting-devel-list] [PATCH] removes unneeded begin/end call notification in text-chat



On sam, 2004-01-24 at 19:07, Damien Sandras wrote:

> > Hmmm... src/common.h has quite a few exceptions...

> I strongly disagree.

Any .cpp that includes src/common.h knows what the implementation of the
text-chat is, and is able to tamper with it.

> > > You will never see that. Global variables, even static, are considered
> > > as a very bad programming practice by many people, including me and I
> > > have put much effort to prevent that to happen.
> > 
> > What I described is not _global_. It is _local_: you don't have access
> > to the variables outside of the scope where they're used, and there's an
> > outside the scope.
> > 
> 
> No they are global in the sense that they are declared outside of the
> scope of a function in a .cpp file. Having them declared as static
> basically doesn't change anything to that fact.

> > On the contrary, variables in a struct that is declared globally, with a
> > function that gives access to it globally, are therefore _global_:
> > there's no scope where you can't access them.
> > 
> huh? You are redifining terms your way ;-)

global: accessible from anywhere
local: not global

> The big difference here is that you have only *defined* the structure.
> You have not instancied the structure and so you don't have a global
> reference to the structure. A structure is like an object, defining it
> doesn't create it. 

  GmWindow *gw = GnomeMeeting::Process ()->GetMainWindow ();
  GtkWidget *text_view = gw->log_text_view;
this is a global reference. Indirect I must admit.

> But with your static-based approach you are clearly defining variables
> that are global to a file.

If they're visible in a single file among several, they're local.

> Though I agree on one point, the GmTextChat definition (for example)
> should be moved from common.h to chat_window.h. The reason of the
> existence of common.h is historic, and we should get rid of that file in
> the future.

Nice. May I propose the so-called "private struct" approach? (See the
attached example for an example.)

> > I agree that global variables should be avoided at all cost.
> > 
> 
> Yes, and you won't get me accept static global variables in any file of
> GnomeMeeting. There is even no need to discuss it or to try to convince
> me. That is my point of view and part of my Coding Policy.

As I said:
> > I'll push things into shape as much as possible through the use of
> > structures if you wish so, since it will be a prerequisite for the clean
> > transition to a GObject anyway, if it happens.

ie: you made a decision, I'll stick to it...

Still, a quick look at the example should make us both happy (and
perhaps it is possible for 1.00 ;-) )

Snark

Attachment: private_structure_example.tar.bz2
Description: application/bzip



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]