Why AMD? - Part 1

Поделиться
HTML-код
  • Опубликовано: 17 сен 2024
  • We'll take a look at the AMD pattern
    Source Files: github.com/Car...
    RequireJS: requirejs.org/
    Find me on Twitter (@CaryLandholt): / carylandholt

Комментарии • 36

  • @JayRGabz
    @JayRGabz 5 лет назад +8

    watching this in 2019 :D

  • @antoniopavicevac-ortiz8886
    @antoniopavicevac-ortiz8886 11 лет назад

    I have to pile on in regards to the sentiment in the comments...
    Adroit presentation!

  • @avimehenwal
    @avimehenwal 3 года назад

    Wow! its still super useful in 2020 :) Thanks for sharing

  • @predikt
    @predikt 12 лет назад

    You're a great teacher. Keep up the good work. Fantastic video

  • @AaSs-vg6ig
    @AaSs-vg6ig 11 лет назад

    Excellent tutorial and very easy to follow.

  • @jasonaables
    @jasonaables 11 лет назад

    Great teaching style. Well done.

  • @carylandholt
    @carylandholt  11 лет назад

    Thanks, Jason!

  • @carylandholt
    @carylandholt  11 лет назад

    Thanks, Antonio.
    You're the first to use "adroit". :)
    Cary

  • @carylandholt
    @carylandholt  11 лет назад

    Thanks, Tony!

  • @carylandholt
    @carylandholt  11 лет назад

    Since we are assigning the "add" variable instead of amending it, we are safe.
    If we were amending to the "add" namespace, we would use the || syntax.

  • @thulasipb123
    @thulasipb123 10 лет назад

    Nice to know about AMD. Thanks for the video

  • @AaSs-vg6ig
    @AaSs-vg6ig 11 лет назад

    Question: I can see how you manage the global name "calculator" from being overwritten but how do you protect your methods like "add" from being overwritten as well? Should the same technique be used (calculator.add = calculator.add || ....)?

  • @saikantabathina514
    @saikantabathina514 12 лет назад

    Great video , Thanks

  • @James-gv8dr
    @James-gv8dr 4 года назад

    terrific

  • @infoa2z
    @infoa2z 12 лет назад

    very nice.

  • @zx1986
    @zx1986 11 лет назад

    thank you so much! 謝謝你!
    very very very good work!

  • @carylandholt
    @carylandholt  12 лет назад

    Thanks!

  • @carylandholt
    @carylandholt  12 лет назад

    Cheers!

  • @carylandholt
    @carylandholt  11 лет назад

    Thank you

  • @carylandholt
    @carylandholt  11 лет назад

    Ahh, thanks. Nice thing to say.

  • @carylandholt
    @carylandholt  11 лет назад

    Cool - thanks!

  • @TonyBrowndesignanddevelop
    @TonyBrowndesignanddevelop 11 лет назад

    Thanks Dude

  • @AaSs-vg6ig
    @AaSs-vg6ig 11 лет назад

    Hypothetically, Isn't possible that another script is also assigning the 'add' variable?

  • @flint0131
    @flint0131 11 лет назад

    Wish you were my prof

  • @beto.aveiga
    @beto.aveiga 8 лет назад

    Ugly code editor jaja... but excellent explanation! Thanks for the tutorial. I'm going to watch part 2 :)

    • @carylandholt
      @carylandholt  8 лет назад

      lol - that was four years ago. Editor is much better now. :)

    • @beto.aveiga
      @beto.aveiga 8 лет назад

      yeah I knew it was an unfair comment... jaja

  • @carylandholt
    @carylandholt  11 лет назад

    It is possible.

  • @mbxmusic7028
    @mbxmusic7028 10 лет назад

    in a real world example those functions would probably still depend on properties and other functions of the calculator object so it won't help just creating a new empty object. Imagine if we had functions or properties on the calculator object that all other functions in calculator share in common. Its good to always keep track on your modules so you know when they are available to you aswell as trying to reduce their dependencies on eachother so that they can be exported to other projects without breaking for example.
    mod.counter = {
    callcount: 0,
    add: function(){
    this.callcount++;
    },
    reset: function(){
    this.callcount = 0;
    }
    };
    modules like this depends on the initialization of the module so we cannot extend it until we have initialized it. And as for the collision risk with global variables you dont always need selfexecuting functions you can build your whole application upon just one global object and be just fine but if you want variables or functions to be kept private i highly recommend this approach:
    var counter = (function(){
    // PRIVATE
    var callcount = 0;
    // EXPOSED
    return {
    add: function()
    {
    callcount++;
    },
    reset: function()
    {
    callcount = 0;
    },
    getCount: function()
    {
    return callcount;
    }
    };
    }());

    • @carylandholt
      @carylandholt  10 лет назад

      The example was arbitrary to lead up to describing the AMD pattern.

    • @dcscott100
      @dcscott100 5 лет назад

      Why, it's almost like Cary has a better solution than the one in this video. As if! :)

  • @MominBinShahid
    @MominBinShahid 5 лет назад

    Link to the second part (2): ruclips.net/video/HwO_qwcJ4rs/видео.html

  • @carylandholt
    @carylandholt  12 лет назад

    Thanks!

  • @carylandholt
    @carylandholt  11 лет назад

    Thanks!