-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

        I am currently starting a new personal project and thought that i would
start to implement it in PHP5. Now the new object model in PHP5 is
really nice and haveing objects bassed by reference by default saves a
lot of head aches :)

        My question however probably comes from my lack of OO understanding.
Lets say i have the following class:

Final class Statistic {
~    function __construct ($min, $max, $initValue=0) {
~    }
~    public function setValue ($value, $strict = false) {
~    }
~    public function applyDelta ($delta, $strict = false) {
~    }
~    public function getValue () {
~    }
}

        I want to implement some kind of onChange function and from what  i can
see that i have 2 options:

        1. Create an OnChange object and make Statistic a child class.
        2. Create an OnCHange interface and make Statistic implement it.

The problem is that nither are fully what i'm after. I want to be able
to use the onChange functionality on a number of other classes (all
implemented in the same way) and i also want to create a few other
onBlah functions that i also want to apply to objects along side if
required the onChange functionality.

So from this i can see that an interface would be the best way to go as
a class can implement any number of interfaces but can only be extend
from one parent. However using the example given all the onChange
functions for each object function exactly the same and will therefore
give me a lot of repeated code.


Is there any way to get around this. Something like an interface with a fully defined function is what i'm really after.

The onChange function is currently...

~    public function onChange ($object=null, $method=null) {
~        if($object == null){
~            $method = null;
~        }
~        if($object != null && !is_object($object)){
~            $this->onChange();
~        }else{
~            $this->onChangeObject = $object;
~            $this->onChangeMethod = $method;
~        }
~    }


-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/shU0zSfrYDJMXmERAr8OAJ9L1lQ5VUkNuHTJLP7jUpHAtSWheQCdF12b
XYoWdVBKzf4eYF3cBaKRamk=
=n8KJ
-----END PGP SIGNATURE-----

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to