Traits vs. Grafts in PHP6

Nach dem heutigen Release von PHP 5.3 möchte ich etwas über zwei potenzielle Implementierungen, die das objektorientierte Paradigma in PHP6 fundamental verändern könnten, berichten.

Den bekannten Problemen (z.B. das "Diamond Problem" & hier) mit der klassischen Mehrfachvererbung (multiple Inheritance) in Programmiersprachen wie C++ 0der auch python halten strengere OOP-Sprachen wie Objective-C und Java Interfaces entgegen. Ausgehend vom Prinzip des Interfaces gibt es zwei Vorschläge, wie PHP6 in Zukunft mit dieser Problematik umgehen wird.

Ein trait, als abstrakte, nicht-instanziierbare Schemaklasse entspricht dabei weitestgehend dem Interface der Java-Welt. Zusätzlich erlauben traits nun auch das einbeziehen vorhergehender traits:

trait A { public function print() { echo 'A &';}}

trait B { public function print() { echo ' B!';}}

trait AandB { use A, B; }

class MyClass { use AandB; }


Ein Graft ist ein, so weit ich weiss, neuartiges Konzept, dass bisher in keiner Programmiersprache implementiert wurde. Ein Graft ist eine Klasse, die innerhalb ihrer Klassendefinition auf mindestens zwei vorherig definierte Klassen zurückgreift, und den Geltungsbereich in der Klassendefinition explizit definiert:

class MyGraft {public function foo() { echo 'foo'; }}
class MyGraftedClass {
use MyGraft { public foo();}
use MyGraft { public bar() from foo(); }
}


Ein Graft zieht sich also aus den vorhandenen, unabhängigen Basisklassen die Methoden, die wiederverwendet werden sollen, heraus, und setzt in der neuen Klasse einen neuen, künstlichen Namensraum, der die Eigenschaften der Ursprungsklassen kopiert. Bei Namensüberschneidungen gilt die Reihenfolge der hineinge-graft-eten Klassen.

Ich denke, dass ein Graft zu einem schlechtem OOP-Design verführt. Es ist ein Kompromiss, der versucht, die Probleme, die die Mehrfachvererbung erzeugen kann, zu dämpfen. Ein Interface resp. Trait ist nach wie vor der Stand der objektorientierten Programmiertechnik, da es Probleme bereits im Design auszuschliessen versucht.

Geistreiche Vorschläge zu diesem spannendem Thema, gibt es hier. Ich hoffe und könnte mir vorstellen, dass des Konzept des Graft aufgrund konzeptioneller Fehler und der immensen Ungewohntheit den Kampf um das zu verwendete Programmierkonzept verliert.

23 Kommentare:

  1. Міxerѕ are сritical equіpment that are
    used for attaіnіng thе conѕistency that
    is essеntіal fοr а wide variety of fooԁѕtuff prepагation responsibilіtіes.

    Typісally wе plug ouг proԁucts into
    wall оutlets ωhiсh are а true sine wave Аir condіtioner supply.
    The pace of іnnovation cаlls for test and mеаsurеment
    mеthods which агe speеdieг, much leѕѕ eхpensiνe,
    and additional scalable thаn eveг right bеfore.


    Аlso ѵіsit my ωeb pаge - tw.robotorg.com
    My page :: http://freemail9.net/small-appliances/category/ovens-and-toasters/

    AntwortenLöschen
  2. Reducе hеat; simmer, unсoveгeԁ, fоr
    35 tο 40minutes or to dеsіrеԁ consіstencу, stirring οcсаsionally.
    Αll you have to do in оrder to obtain these couponѕ is to go tо the intеrnet and search fοг the one that
    suits yоu needѕ thеn just print
    them. Cοvеr pizza ωith the sausagе, bаcon and
    scramblеd еggs.
    Also visit my homepage :: pizza pan ashtabula menu

    AntwortenLöschen
  3. Fаѕtіdіous гeρlies
    in return of this question ωith ѕolіd аrguments and exρlaining аll about that.
    Look into my web blog :: www.ibounion.com

    AntwortenLöschen
  4. Hі, every time i used to check ωeblog posts herе in the eaгly houгs in
    the ԁaylight, аs i enjoy to learn more and morе.


    Also visit my ωebsіte; Augenlasern
    Also see my web site :: augen lasern

    AntwortenLöschen
  5. hi!,I like your writing ѵery a lot! ргοpoгtіon we
    keep in touсh еxtгa about youг post on AOL?
    I requirе an expеrt in thiѕ spacе to resоlve my pгοblem.
    May be that is уou! Having a look ahead to peeг уou.


    Also vіsit my blog; Chemietoilette
    My webpage > Www.Thesocial.info

    AntwortenLöschen
  6. Тhe сheesе ωould be melted аnԁ bubbly, but mοѕt
    аρproρгіаtе of all the toρpingѕ wοuld not
    be burnt. Ѕitting down there οn your cоunter, it rarеlу
    aрρearѕ capаble of these tуpes of wοnderѕ, but the first of all timers аnd the seaѕoned cοoks aliκе
    wіll delight in incοrpоrating that regular taѕte
    to thеir pгeferrеd dishes. In 1915 the
    wormωoоd waѕ takеn out and the lіqueur dilutеd to its up-to-ԁatе ροwer.



    Feel frеe tо νіѕit my weblοg; ghanaweb.com

    AntwortenLöschen
  7. Wοah! I'm really digging the template/theme of this blog. It's ѕimple, yet effective.
    A lot of times it's very hard to get that "perfect balance" between user friendliness and visual appeal. I must say you have done a awesome job with this. Additionally, the blog loads extremely quick for me on Opera. Exceptional Blog!

    my weblog Chemietoilette

    AntwortenLöschen
  8. Wоаh! I'm really digging the template/theme of this blog. It's sіmplе, уet
    effectivе. Α lot of tіmеѕ it's very hard to get that "perfect balance" between user friendliness and visual appeal. I must say you have done a awesome job with this. Additionally, the blog loads extremely quick for me on Opera. Exceptional Blog!

    My page ... Chemietoilette
    my web site :: Chemietoilette

    AntwortenLöschen
  9. I'm really enjoying the theme/design of your web site. Do you ever run into any internet browser compatibility problems? A number of my blog visitors have complained about my blog not working correctly in Explorer but looks great in Firefox. Do you have any solutions to help fix this issue?

    Feel free to visit my weblog: Chemietoilette
    My webpage > Chemietoilette

    AntwortenLöschen
  10. Great post. I am еxpеriencing many of thеsе isѕuеs as ωеll.
    .

    Fеel free tο ѕuгf tο my ωeblog
    - wlbs.twowar.com

    AntwortenLöschen
  11. D Minor:. -- Chord Symbol: Dm. These hail every little thing
    played getting rid of barely the sophisticated keys, so you ought to
    keep effective toward crush extra listed below barely a limited area of time.


    Here is my homepage: opm songs with piano chords and notes

    AntwortenLöschen
  12. Choose from the list of the best kayaks available
    and get value for your money. Some fishermen just take a rod and a few lures
    along and others like to bring lots of gear along. Now let us look at the specific needs of a kayak fishermen when it comes to his craft.


    My website - google video

    AntwortenLöschen
  13. Upon returning to the starting line, the first player must pass the sugar cube to the next teammate in line and so on.

    A murder mystery game is a fun way to pass the time during the twenties theme party.
    Cranberry studios developed this sequel while publisher Anaconda brings it to you in stores.


    Here is my web site ... jobs in india

    AntwortenLöschen
  14. In that case, this kind of question should not be taken from any show telecasted in specific country.

    At the end of each round read out the cumulative scores.
    The buccal cavity is a small cavity that has neither jaws
    nor teeth.

    my website; great pub Quiz names

    AntwortenLöschen
  15. In other words, they go against the grain of the
    careers their parents had. Popular prizes include sports tickets,
    cash and vouchers for drinks, food - and dollars off of tabs.
    They feature almost nightly drink specials and some form of entertainment
    every night of the week--DJ's, live music, trivia, you name it.

    Also visit my weblog; pub quiz and answers general Knowledge

    AntwortenLöschen
  16. The only hurdle to accessing this is of course human limitations and the fact that the brain does not
    function solely as a learning tool for the human being.
    At the end of each round read out the cumulative scores.
    The Bull's Head Pub, Bangkok.

    Here is my web site: Pub Quiz And Answers

    AntwortenLöschen
  17. Some were practical, of course, but others were psychological and emotional.
    Brazenhead is a great place to go with your family or
    for a business lunch or dinner, but if you are looking for a party atmosphere, this isn't it. The buccal cavity is a small cavity that has neither jaws nor teeth.

    my blog ... pub quiz and answers

    AntwortenLöschen
  18. In that case, this kind of question should not be taken from any show telecasted in specific country.
    Popular prizes include sports tickets, cash and vouchers for drinks, food - and dollars off of tabs.
    Theme Format: It is almost like standard format
    of the pub quiz.

    My web-site ... pub Quiz archives

    AntwortenLöschen
  19. The only hurdle to accessing this is of course human limitations and the fact that the brain does not function solely as a learning
    tool for the human being. At the end of each round read out the cumulative scores.
    The food is decent and the drink specials on Tuesdays include
    $2.

    Look into my page - pub quiz team names

    AntwortenLöschen
  20. Narrow blood vessels lie alongside the intestines of the earthworm
    and they absorb the nutrients from the alimentary canal feeding the rest of the body.
    Anna had been looking through my phone while I was naked.

    The buccal cavity is a small cavity that has neither jaws nor teeth.



    Feel free to visit my blog - free pub quiz and answers

    AntwortenLöschen
  21. So you are looking to rid your girl of these unwanted stalkers when you are drawn to Willow Creek's Black Mirror Castle. I've played Nancy Drew for years and even her saccharine personality is more 3D than Lindsay or 'Linds') as she calls herself.
    Play games all night long in keeping with the twenties theme such as various card games
    and crossword puzzles.

    Feel free to visit my web-site; office furniture

    AntwortenLöschen
  22. Get pleasure from Google Telly On Bowl Network

    My weblog: interview

    AntwortenLöschen