Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Concerning SplSubject and SplObserver [RSS Feed]

#1 Nov. 16, 2005 20:46:27

Johannes H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Concerning SplSubject and SplObserver


Hello,

There has already been a discussion about this with the subject "Subject
and Observer Interfaces" opened by Jeff Moore. I must say that I
completely agree with Marcus Boerger on this subject.

It is not difficult to extend Subject and Observer so you can pass
additional information to the Observers, just design it so that it's
compatible with Observers too. This can be done by introducing optional
method arguments. Something like:

interface KeySubject extends Subject {
function attach(Observer $observer, $key = null);
function detach(Observer $observer, $key = null);
function notify($key = null);
}

This interface is a Subject which will notify only Observers which are
registered at a specific key (useful for configuration classes where
only one part of the program has to be notified about one part of the
configuration.)
The implementing class should treat keys with a null value as attaching
a key-wide/global observer which should be notified of *any* change.

This is backwards-compatible with the Subject interface, as well as
introducing some new Subject functionality.

First of all, I must say that I'm disappointed about the renaming of the
Subject and Observer interfaces to SplSubject and SplObserver. The whole
POINT of SPL is to be a STANDARD PHP Library. It already provides other
interfaces with very generic names like Iterator, generic Exceptions,
etc. In my opinion, those interfaces are complete and fully extendable,
and should be treated as STANDARD interfaces, as SPL suggests.

I'm not sure why this renaming was done, either because of Andi Gutmans'
comment, or something else. Please clarify, Marcus!

Regards,
--
Johannes H. Jensen <>
deworkssignature.ascDescription:This is a digitally signed message part

Attachments:
attachment signature.asc (189 bytes)

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Concerning SplSubject and SplObserver [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support