tami: Sprachregelung

Beitrag lesen

hi tami,

hi molily,

Hallo,

»new« ist nicht fehlerträchtig. Es tut das, was es soll, sehr gut. Es ist nur verwirrend und schwierig zu verstehen. Es sieht wie Java und klassenbasierte OOP aus, ist aber intern etwas anderes. Das ist ein bekannter Designfehler in JavaScript. Dasselbe gilt für »this«.

»new« macht nichts besonders, darunter stecken einfache Objekte, Konstruktoren und Prototypen. Wenn man das verstanden hat, kann man es sicher anwenden. Das tun tausende von Projekte auch.

Ich schreibe beruflich hauptsächlich Pseudoklassen in CoffeeScript, instantiiere sie mit »new« und arbeite mit CoffeeScripts Method-Binding. Das klappt hervorragend und ist gut lesbar. Ich wüsste nicht, was ich da alleine mit dem Verzicht auf »new« gewinnen würde. ECMAScript 6 wird »syntactic sugar« für Klassendeklarationen haben, die CoffeeScript und TypeScript sehr ähnlich sind. Das zeigt, dass diese Schreibweise weiter bleiben wird.

Da seh ichs ;-):

sam = new Snake("Sammy the Python");

tom = new Horse("Tommy the Palomino");

  
Und da ich ja nicht editieren kann, kommt es noch hinten an:  
  
<http://www.artandlogic.com/blog/tag/crockford/> - der Vergleich zwischen Coffee-Script und der "Crockford-Version" - darin u.a. [Zitat]: "Which One?  
  
So which method is better? Because I’m more familiar with class-based inheritance, I’d rather just use CoffeeScript and ignore the underlying JavaScript implementation altogether. I like the fact that I can look at a CoffeeScript class definition and see on a single line both the name of the “class” and the name of the “class” it extends. In both JavaScript implementations, I have to search other lines to find the object that my object is extending. I find the use of the \_\_super\_\_ property a much more elegant solution when it comes to super methods. The functional method for accessing super methods would not scale well if there are a large number of super methods you want to access."  
  
mfg  
  
tami
0 64

Variable übergeben von einer Funktion in eine andere Funktion

chris1234
  • javascript
  1. 0
    tami
    1. 0
      Martin R.
      1. 0
        tami
        1. 0
          Martin R.
          1. 0
            molily
            1. 0
              Martin R.
  2. 0

    Funktionsparameter

    molily
  3. 0
    Tom
    1. 0
      chris1234
  4. 0
    hotti
    1. 0

      Sprachregelung

      Tom
      1. 0
        tami
        1. 0
          tinita
          1. 0
            tami
            1. 0
              tami
              1. 0
                unknown
                1. 0
                  tami
                  1. 0
                    unknown
                    1. 0
                      tami
                      1. 0
                        unknown
                        1. 0
                          tami
                          1. 0
                            unknown
                            1. 0
                              tami
                              1. 0
                                unknown
                                1. 0
                                  tami
                          2. 0
                            molily
                            1. 0
                              tami
                              1. 0
                                molily
                                1. 0
                                  tami
                                  1. 1
                                    1UnitedPower
                                    1. 0

                                      Sprachregelung - "new" in JS

                                      tami
                                      1. 0
                                        tami
                                        1. 2

                                          Von ewigen Zitaten und lieblos eingeworfenen Links

                                          1UnitedPower
                                          • zu diesem forum
                                          1. 0
                                            1UnitedPower
                                            1. 0
                                              Tom
                                              1. 0
                                                1UnitedPower
                                              2. 0

                                                verlieren und vergessen wie in echt

                                                Auge
                                              3. 0
                                                Matthias Apsel
                                              4. 0
                                                Christian Kruse
                                                1. 0
                                                  Tom
                                                  1. 0
                                                    Christian Kruse
                                                  2. 0
                                                    tami
                                            2. 0
                                              tami
                                            3. 0
                                              tami
                                          2. 0
                                            tami
                                      2. 0
                                        1UnitedPower
                                        1. 0
                                          tami
                                  2. 0
                                    molily
                                    1. 0
                                      tami
                                    2. 0
                                      tami
                                    3. 0
                                      tami
                                      1. 0
                                        tami
                                        1. 0
                                          molily
                                          1. 0
                                            tami
                                            1. 0
                                              molily
                                        2. 0

                                          Sprachregelung - Fehler im Beispielcode

                                          tami
      2. 0
        molily
        1. 0
          Tom
          1. 0
            molily
        2. 0
          tami
          1. 0
            molily
          2. 1
            molily
            1. 0
              tami