At 11:01 09.04.2002, Kristian Koehntopp wrote:
>On Mon, Apr 08, 2002 at 08:57:09PM -0400, fabwash wrote:
> > My vote is "java" like: no MI, no aggregation, single inheritence and 
> use of
> > interfaces :)
>
>Could you please explain how interfaces promote code reuse?

An interface in Java is a fully abstract class *without* member variables 
and only
abstract methods. Therefore it is only a list of methods that has to be 
implemented
in a class that *implements* that interface. All done at compile time.

class <class_name> [extends <defined_class_name>] [implements 
<interface_list>] {
         <member_list>
}

we would need additionally:

interface <interface_name> {
         <method_list>
}

See also: http://marc.theaimsgroup.com/?l=php-dev&m=101802194813079&w=2

So in first step it would only be code reuse if the interface had code like 
in COM.

But it is a good design help.

Taking streaming as an eample:

Interfaces:
You design a collection of class that handles streaming and design one 
interface
that has to be implemented in classes that should be streamed. Then for 
every class
you design the only thing to is implementing that interface and it works. 
This is all
done at compile time (although it could be done at runtime, too).

Compared to MI:
When using MI or aggregation every class that has to be streamed will get a 
copy
of the streaming class (what was the interface before).
For MI you get class A extends B, Streams what means you have all members and
methods of B and streams. So MIis the same as interfaces with code at 
compile time.

Compared to aggregation:
For aggregation you can either have above or having Streams as a member object
with methods in A only doing method calls on Streams but with access rights 
in A.
Depends on the implementation of aggregation.

 From the other side:
Every code (procedural and OO) can have an interface as a public wrapper class.
Then it has code and the interface does hiding the actual implementation. 
That is
what COM is about. AND it is a very good way to allow communication between
objects without knowing about a the actual implementation AND it works 
completly
at runtime. As everything is available at runtime you do not have to worry 
about what
language a COM component was written AND your compiler can build the interface
to use. So it works at compile time, too.

marcus


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to