Tuesday, June 30, 2009

Wrapping Paper Holder 42'

Traits vs. Grafts in PHP6

would After today's release of PHP 5.3
I do something about two potential implementations that could change the object-oriented paradigm in PHP6 fundamental report.
the known problems (eg the "
Diamond problem ) with the classical multiple inheritance (multiple inheritance) in programming languages like C + + 0r python also keep tighter OOP languages such as Objective-C and Java
interfaces
contrary. Based on the principle of the interface there are two proposals to PHP6 will deal with this problem in the future.
A trait, corresponds to an abstract, non-instantiable class schema the greatest possible extent the Interface
the Java world. In addition traits allow

now also include the previous
traits:
trait A {public function print () {echo 'A &';}} trait B {public function print () {echo 'B!';}} trait AandB {use A, B;}
 class MyClass {use AandB;} 





A graft is, as far as I know, novel concept that so far has been implemented in any programming language. A graft is a class that the previous within their class definition to at least two defined classes falls back, and defines the scope in the class definition explicitly:

class MyGraft {public function foo () {echo 'foo';}}
class MyGraftedClass {
use MyGraft {public foo ();}
use MyGraft { public bar () from foo ();}
}
 A graft extends thus from the existing, independent base classes, the methods to be used again out, and sets in the new class a new, artificial namespace the properties of the source classes copied. By name duplication, the order of hineinge-graft 

-eten classes.




I think that a graft
a bad OOP design seduced. It is a compromise that attempts to the problems that can generate multiple inheritance to dampen. A Interface respectively.
trait is still the state of the object-oriented programming technology, as it tries to rule out problems at the design.

Spiritual proposals on this exciting topic, it is here . I hope and I would imagine that the concept of graft loss due to conceptual errors and the unfamiliarity of the immense struggle to use the programming concept.

0 comments:

Post a Comment