🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.c++
Article #93

Re: Aufrufer einer Methode feststellen?

#93
From: Armin M. Warda
Date: Mon, 14 Aug 1995 08:03
51 lines
2158 bytes
Hello,

> I don't see the utility. In fact, you have a high chance of making the
> coupling between classes stronger (violating good OO practice).

Agreed.

> The parameter idea _would_ work. But, my question is _why_ would the
> behaviour of an object's operation need to depend on its client.

It's just this: when I view 'method-calling' as 'message passing'
the receiver wants to know the identity of the sender. Fullstop.

> Furthermore, suppose someone writes a class that uses yours;

That class should of cause be at least a Y, should have Y as a
base class.

  class X
  {
    public:
      void f(int x, Y* caller=NULL)
      {
        if (caller)
          if (caller == ...)
            ...
            caller->...;
            ...
          else
            ...
        else
          ...
      };
  };

>                                                              because
> his methods are not in your if/else if/else if/... or switch blocks,
> what would happen? What of reusability?

One application I think about might be: 

an object of class X simply keeps track of all objects of class Y which 
call X::f. When an object of class Y calls X::f for the second time this
called method could behave differently than at the first call.


A.
-- 
-------------------------------------------------------------------------------
Armin M.Warda   <http://ls4-www.informatik.uni-dortmund.de/QM/MA/warda/pi.html>
Universitaet Dortmund,  Fachbereich Informatik, Lehrstuhl IV,  D-44221 Dortmund
Technical Details
Message-ID: <40n00n$r8t@fbi-news.informatik.uni-dortmund.de>
Path: arc1-ca.pugleaf.net!Informatik.Uni-Dortmund.DE!veronica!warda
References: <40clg8$oej@fbi-news.informatik.uni-dortmund.de> <1995Aug10.135331.8957@wavehh.hanse.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!Informatik.Uni-Dortmund.DE!veronica!warda
From: warda@veronica.informatik.uni-dortmund.de (Armin M. Warda)
Newsgroups: de.comp.lang.c++,comp.lang.c++
Subject: Re: Aufrufer einer Methode feststellen?
Date: 14 Aug 1995 08:03:35 GMT
Organization: CS Department, Dortmund University, Germany
Sender: warda@informatik.uni-dortmund.de (Armin M. Warda)
Message-ID: <40n00n$r8t@fbi-news.informatik.uni-dortmund.de>
References: <40clg8$oej@fbi-news.informatik.uni-dortmund.de> <1995Aug10.135331.8957@wavehh.hanse.de>
NNTP-Posting-Host: veronica.informatik.uni-dortmund.de
Keywords: caller, this