Many thanks, Moritz, that could be a v. useful approach. 

Atb,
Oliver
 

-----Original Message-----
From: Moritz Hoffmann [mailto:[email protected]] 
Sent: 11 May 2012 06:07
To: [email protected]
Subject: Re: [Oorexx-devel] ooDialog - Event Handlers - PRIVATE method?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 05/10/2012 08:20 PM, Oliver Sims wrote:
>>> If it raised a question in your mind, I'm sure there are other 
>>> people
> starting out that would have the same question.
> 
> My conscious thought processes were trivial. I think I just assumed 
> that event-handling methods could be private, even though I knew that 
> it's code in ooDialog that actually invokes the method. For what it's 
> worth, and after a little introspection, I found that my "no-think" 
> approach was along these lines: (1) I've got an event handler such as 
> "::method doThis". (2) This is a public method since private isn't 
> specified. (3) I don't want an event-handling method to be public. (4) 
> So make it PRIVATE.

You are very right with trying to protect event handler methods. In ooRexx,
the only way to do this is to have a second class that is contained by the
outer class. The second class has methods for handling events. When the
outer class is constructed, it also creates an instance of the event handler
class, which is then registered where necessary. It would be something like
this:

::class outer
::method init
  expose eventHandler
  eventHandler = .MyEventHandler~new(self)

  -- now the event handler can be registerde...

::class MyEventHandler
::method init
  expose container
  use strict arg container

::method doThis
  expose container
  container~whatever
  -- can do more complicated stuff here

(just written off my head, so excuse any syntax errors ;-)

Now the problem will be that the outer class needs interfaces to communicate
with the event handler, which is the same problem you mentioned. However, it
can be solved by using another object that encapsulates the data and is
shared by both object.

Another approach is to have public and private classes together with a
factory:

Class PublicClass
Class PublicClassImpl extends PublicClass

In ooRexx, we don't need explicit factories as classes can override ~new to
return an instance of a different class. This does not prevent foreign code
to call your protected interfaces, but at least you can state that it's not
part of your API.

Best,
Moritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk+srHsACgkQ264ap80Va8caMwEAqrifPt8Ft2+MHKegoSpftiZr
ojqAOhvqTX9JIc2KTm4A/igKPwLMCGILEFh2q8+kBeSTJQjzksTQGXA43OPokdK8
=JkQQ
-----END PGP SIGNATURE-----

----------------------------------------------------------------------------
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat
landscape has changed and how IT managers can respond. Discussions will
include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to