JavaScript object creation patterns tutorial - factory , constructor pattern, prototype pattern

Поделиться
HTML-код
  • Опубликовано: 10 ноя 2024

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

  • @slashpl8800
    @slashpl8800 7 лет назад +163

    1:08 Factory pattern
    7:36 Constructor pattern
    12:20 Prototype pattern
    24:00 Dynamic prototype pattern
    Needed 4 myself, but hope it'll be useful for anyone. Great tutorial btw :)

    • @shibatadashi
      @shibatadashi 7 лет назад +11

      not all heroes wear capes :)

    • @mdhabiburrahman7386
      @mdhabiburrahman7386 6 лет назад

      M not clear about Dynamic prototype pattern. function method is created one time in constructor pattern too. so why if condition here?

    • @javierpacareu
      @javierpacareu 6 лет назад

      The condition is there because it would override the method over and over once you create an instance of "peopleDynamicProto" object. You could check it by placing a console.log right inside the if statement and set the if to "true"

    • @vinothkumarv9722
      @vinothkumarv9722 4 года назад

      Its really good bro..

  • @sahanapk
    @sahanapk 5 лет назад +12

    For the first time I understood design pattern with ease. Your teaching skills are unique and excellent. I am big fan of your tutorials. Thank you :)

  • @rs459
    @rs459 8 лет назад +17

    I think you could tell, you can have default value like that,
    var People = function (age) {
    this.age = age || 23; // 23 become the default value otherwise.
    }
    or eventually with es6, like that :
    var People = function (age = 23) {
    this.age = age;
    }

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

      this.age = age || 23 // will give you 23 if you want to pass 0 or empty string cause they're falsy values. Your ES6 example is better

  • @SunilKumar-fh6jk
    @SunilKumar-fh6jk 6 лет назад +5

    Give this guy a like! Teaching slowly but steady. Thank you!

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

    When i am trying to learn Java script i saw so many websites but i could able to understand and also i dnt have any confidence on javscript after watch these tutorials i have got a lot of confidence on java script .thank you TECHSITH.

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

    Coming from python,I can easily relate to the constructor "method" where instead of this.name=name;this.age=age;this.state=state; it was self.name=name/self.age=age/self.state=state(of course indented).Same with the function definition below - just replace "this" with "self" ,console.log() with print(),take out the semicolon and you have pythonAnd you would do just like in the video to instantiate an object from a class in Python.Apply the same technique in javascript.So nice to see that you can apply concepts from other OOP language here to learn the specifics of javascript faster.

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

      JavaScript has lot of concept from python so i think you will feel bit familiar.

  • @tuppas
    @tuppas 7 лет назад +46

    he never notice the peron function instead of a person

    • @javierpacareu
      @javierpacareu 6 лет назад +5

      i speak spanish and i was like wtf is Peron? XD Is like singular of People? I didn't know that LOL

    • @mervinmarias9283
      @mervinmarias9283 4 года назад

      When he smoothly continued the lesson including the typing error, I knew he knew his shit.

  • @DheerajAgrawal00
    @DheerajAgrawal00 6 лет назад

    This was very well defined tutorial, it makes everything clear now which I read before like how the prototype works and how you create the constructor, how you can achieve OOPS in javascript. In all the patterns I found Dynamic prototype pattern most useful, since it gives you the constructor and prototype pattern both, also its space efficient

    • @Techsithtube
      @Techsithtube  6 лет назад

      To learn more about OOPS in JavaScript I have a tutorial series ruclips.net/p/PL7pEw9n3GkoW0ceMeoycg9D00YjPAbtvt

    • @DheerajAgrawal00
      @DheerajAgrawal00 6 лет назад

      Its looking good series, surely I will go through this, thanks a lot

  • @marcusgreen2838
    @marcusgreen2838 7 лет назад +1

    great explanation. It has helped me immensely to understand not only OOP and JavaScript but how creational design patterns work.

  • @Sindoku
    @Sindoku 6 лет назад

    Thank you! I have been looking for this video for several days now, and I finally found it!! I now know the strongest way to build objects in objects using OO programming concepts in JS.

  • @dubeykivines9202
    @dubeykivines9202 4 года назад +1

    Mind blowing tutorial Sir. I had never understood this concept so clearly. Thanks for your help 👍.

  • @RajeevRanjan-gl5nh
    @RajeevRanjan-gl5nh 8 лет назад

    Talent is what God gives us, Skill is what we give back to Him............Big Thank you :) !

  • @NatureFreak1127
    @NatureFreak1127 7 лет назад +1

    This is the best tutorial I have come across so far, thank you very much.

  • @vagnonivagnoni
    @vagnonivagnoni 9 лет назад +1

    Best tutorial class javascript in you tube.

    • @Techsithtube
      @Techsithtube  9 лет назад

      +Vagnoni Vagnoni Thanks you . I am glad you learn something from it. :)

  • @maxwelllasky4346
    @maxwelllasky4346 9 лет назад

    This is a great video! One piece of feedback is constructor functions should typically have their first letter capitalized as in:
    var PeopleFactory = function(name, age, state){
    this.name = name,
    this.age = age,
    this.state = state
    };

    • @Techsithtube
      @Techsithtube  9 лет назад

      +Maxwell Lasky Thanks for the feedback. I will keep that in mind.

    • @smoothbeak
      @smoothbeak 9 лет назад

      +Maxwell Lasky Why would you call a constructor function 'factory'? :P

    • @Techsithtube
      @Techsithtube  9 лет назад

      I guess in javascript everything is made of functions. and functions are also constructors . Hence the constructor function 'factory' ;)

    • @maxwelllasky4346
      @maxwelllasky4346 9 лет назад

      +Daniel Jeffery I was really just trying to put it in in the context of the video because +techsith named the function declaration 'peopleFactory'

    • @Techsithtube
      @Techsithtube  9 лет назад

      haha.. It's the Revenge of the sitt, using the factory created clones. :)
      FYI: Looking forward to the The Force Awakens

  • @drewpeer
    @drewpeer 6 лет назад

    I love the detail in the video. What I want to see in tutorials is using these objects in simple applications with more useful output. Everyone just prints out text. Do things that make programing more useful. Like showing how many lines of code it takes to do something purely functionally, then object oriented. -Keep up the great work!

    • @Techsithtube
      @Techsithtube  6 лет назад +1

      Andrew, I have created a series specifically for that, where i teach object oriented programming using constructor/prototype pattern and mixins using factory pattern. check out the series here ruclips.net/p/PL7pEw9n3GkoW0ceMeoycg9D00YjPAbtvt

    • @drewpeer
      @drewpeer 6 лет назад

      Thanks so much!

  • @kavitha1282
    @kavitha1282 6 лет назад

    Very nice tutorial.. Very well explained, day to day when we do coding we do use this but we dont know these all are the patterns.. Now I can proudly say I know Javascript design patterns.. Thank you techsith :)

    • @Techsithtube
      @Techsithtube  6 лет назад

      Yep, we use lots of patterns day to day basis but we dont know what they are. :)

  • @shrikantpatil4797
    @shrikantpatil4797 6 лет назад +1

    Thank you, very good explanation with code. I would request you please make a sample project and apply all the concepts which we have learnt in this video so we will have more clear idea about the concepts.

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

    Very Good Tutorial. Clearly and properly explained advance concepts

  • @sayhongtan8993
    @sayhongtan8993 8 лет назад +1

    Object creation patterns explained very clearly and with examples!

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

    @techsith the Dynamic Prototype seems breaks the responsibility of the a Constructor, where the responsibility should be just initialize the properties for the object being constructed.
    For a given case when I want to inherit a given object's prototype -
    Emp.prototype = Object.create(Person.prototype);
    But, in case of Dynamic prototype pattern we have to -
    // Create the first Object 1st
    // Until below line executes the Person.prototype.printPerson won't be available
    var p1 = new Person('John', 20, 'CA');
    // Then inherit the prototype
    Emp.prototype = Object.create(Person.prototype);
    Please share your opinion. Thanks in advance.

  • @branislavcepilek4064
    @branislavcepilek4064 7 лет назад +8

    Great tutorial. Very clear. Thank you.

    • @snø_music0
      @snø_music0 7 лет назад

      you have a very different perception of "clear" than most people.

  • @vinothkumarv9722
    @vinothkumarv9722 4 года назад

    Sir i am really amazing i can clearly understood.. i love your channel i will support you always.....:)

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

    How can anyone dislike this amazing tutorial? I am amazed! Thank you techsith

    • @Techsithtube
      @Techsithtube  8 лет назад +2

      +Baba Michael Thanks for really nice comment. I really appreciate people writing positive comments. This really encourages me to make more videos. As for disliking the video, i there there are few following reasons why people do it.
      1) Some time they accidentally push unlike button in hurry but their real intention is to click like button.
      2) They find sometime typo, or some other spelling errors ( i think this is really a wrong reason to unlike someones video).
      3) Some people find the video misleading because they were looking for something completely different topic ( i dont think my videos fall in that category)
      4) some people are just bitter.
      Well so, you or anyone thinks these are good or valid reasons to unlike someones video.? I would like to know so i can improve .
      Thanks

  • @shankarmishra426
    @shankarmishra426 7 лет назад +1

    wow...great tutorial explains all the object creation patterns with single syntax...

  • @QwertyNPC
    @QwertyNPC 8 лет назад +2

    I'm not sure if when you say that this.value (around 9:00) is a property of the constructor you are not misleading a bit. If you called the function by invoking it normally you’d actually augment the global object, so it is more precise to say that “this” inside the constructor is: the global object if you call it as a regular function, or an implied returned object if you use the “new” keyword. Also, it is best practise to capitalize first letters of constructor names, and it is pointless to put properties on the prototype. Typically you only put methods there.

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

    Excellent explanation. Just a feedback to make people understand Prototype Pattern better upload one video on prototype.
    e.g. What is prototype?
    Actually in prototype pattern we are utilizing the concept of prototype i.e. every object is associated with another object or in short every object has a prototype object associated with it and an object inherits properties from it.
    In the prototype pattern we just took advantage of that concept. The beauty is we have achieved inheritance too. Just remember again we didn't set name yet we got the default just because of the base class which in java script is prototype object.
    Keep it up. Thanks for sharing your wonderful knowledge.

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

      +Ashish Kalra Thanks for the suggestion. I am in process of making a video on prototype.

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

      +Ashish Kalra Hi I just released a tutorial on prototype. please check it out ruclips.net/video/7oNWNlMrkpc/видео.html
      i have part -2 of this tutorial coming up in few days.

  • @newthepanch
    @newthepanch 7 лет назад

    thanks for this man, ive been doing asp.net for about 8 years, but honestly i havent used javascript that long since microsoft made us lazy with all that ajaxframework and stuff thanks im doing this tutorials

    • @Techsithtube
      @Techsithtube  7 лет назад +1

      I had a similar situation . worked on asp.net c# for sometime and lost most of the other skills. All the new JavaScript frameworks work differently so I had to get used to it for good.

    • @newthepanch
      @newthepanch 7 лет назад

      techsith so what do you suggest to do in order to keep the rythm on the technology and make use of it the way you should

    • @Techsithtube
      @Techsithtube  7 лет назад

      I would suggest. start a GitHub page, and a project in React or similar framework and build your project. Use all the latest tools. git, Linux, atom, etc...

  • @imfakeid
    @imfakeid 7 лет назад +1

    best tutorial on objects so far

  • @jesusnana11
    @jesusnana11 6 лет назад +1

    @techsith, thank you for this very clear explanation. I learned a lot from your videos. :) I have 1 question regarding Factory Pattern. Why did you use this.name, this.age, this.state inside printPerson(). Does 'this' on printPerson() doesn't change context? Thanks again!!!

    • @Techsithtube
      @Techsithtube  6 лет назад

      One rule of thumb is . if printPerson() is a method or the object than "this" inside the printPerson means the object. but if its a regular variable then it gets its own scope. and this.name is going to be undefined as its not bind to the outerscope.

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

    beautifully and simple explanation. thank you very much.

  • @n.saravanannsaravanan8545
    @n.saravanannsaravanan8545 6 лет назад

    Simple examples, straight to the point explanation thanks for these tutorials, please do more, I will buy it :-)

  • @thoughtsole1880
    @thoughtsole1880 7 лет назад

    this tutorial very helpful to understand how different ways we create object

    • @Techsithtube
      @Techsithtube  7 лет назад

      for the factory pattern the syntax in that video is old. try new syntax in this video using object.assign ruclips.net/video/9Ky4X6inpi4/видео.html

  • @kamleshpawar4418
    @kamleshpawar4418 6 лет назад

    Best tutorial on object creation.

  • @my2talent
    @my2talent 6 лет назад

    your tutorials are really clear and understandable , good job

  • @JeyPeyy
    @JeyPeyy 4 года назад

    Coming 5 years later - with ES6 having introduced const, let and template literals, and later versions even more goodies - seeing your way of coding makes you look like a beginner lol, but that's how people coded back in the days. I still don't like the class keyword that was introduced in ES6 because it abstracts what will show up in the browser's devtools, so different patterns for object creation is still good to learn about.

  • @motiurrahman222
    @motiurrahman222 7 лет назад

    i get clear cocept of cactory pattern in this tutorial... thank a lot...

    • @Techsithtube
      @Techsithtube  7 лет назад

      I am glad. thanks for watching! :)

  • @MattBellButterfly
    @MattBellButterfly 9 лет назад +23

    var Person = function(name, age, state){
    this.name = name,
    this.age = age,
    this.state = state
    };
    Person.prototype.print = function() {...};
    that's all you need.

    • @OneAndOnlyMe
      @OneAndOnlyMe 8 лет назад +4

      +MattBellButterfly That's one way. The other patterns are useful to know too.

    • @GifCoDigital
      @GifCoDigital 8 лет назад +3

      +MattBellButterfly thats NOT all you need to know. Prototypal has a lot of benefits and is pretty much the new standard, classical is old school.

    • @jayel9809
      @jayel9809 6 лет назад

      I was really wondering why he didnt do it this way tho, its functionally the same, with less code, and seems to read better. You have your constructor, plus all of its prototype definitions..

  • @theguy9067
    @theguy9067 6 лет назад

    The most clear and readable is the constructor pattern. I don't see a benefit in the others other than memory usage. But how much does this actually affect performance?

  • @robysoriano2956
    @robysoriano2956 7 лет назад +1

    Hello Sir. Nice tutorial huh. This will help me a lot. As you said in the last part of your video, we can ask you what topic we want, can you provide us an practical example using objects? Thank you Sir! Have a good day!

  • @philf4018
    @philf4018 7 лет назад

    Dynamic Prototyping: Whats the advantage of checking for the print-function compared to just assign it to the prototype outside of object-function? For me, the check adds more complexity to it, that is not needed.

    • @philf4018
      @philf4018 7 лет назад

      Ah, its just the visual aspect of keeping the print-function inside the object.

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

    Each of the Objects you created were functions, I have been playing around trying to learn JS and created my Objects using an name:value Object with just the vars in the Object itself and any function built out of the Object itself like your prototype design only not using the word 'prototype'. Could you do a short lesson on the difference between these and why one may be prefered over the other? This was a great lecture thanks

    • @Techsithtube
      @Techsithtube  8 лет назад +1

      i do have a tutorial on prototype inheritance. you can check it out.
      in nutshell adding method directly in the object creates heavy objects. if you create another object from it it will have a copty of those methods. While prototype methods are more like a refrence.

  • @MarreLirre
    @MarreLirre 7 лет назад +1

    Very good and easy tutorial, exactly what I was looking for!

  • @rpscontent5469
    @rpscontent5469 6 лет назад

    U r grt sir...n JavaScript are so easy after watching yr video..

    • @Techsithtube
      @Techsithtube  6 лет назад

      I am glad that it's helping you. Thanks for watching! :)

    • @rpscontent5469
      @rpscontent5469 6 лет назад

      Hi sir, kindly suggest how to improve coding skill ...

    • @Techsithtube
      @Techsithtube  6 лет назад

      What level are you at right now? I would suggest creating a project on GitHub and try to build it using JavaScript. This will keep you focus. Try to work atleast twice a week on it .

  • @injrav
    @injrav 8 лет назад +1

    very good and nice explanation.
    On first method i.e. factory.. what would be the problem if method code is replicated with all the objects.. I think once object done its job,, it will be out of HEAP.

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

      +inj rav factory is nice pattern that allows you to compose object and the method that creates the object can be used to create diffrent objects . and yes once the object is done its job its will be out of Heap

  • @KhayyamNaghiyev
    @KhayyamNaghiyev 7 лет назад +1

    THANK YOU!!!!!!!wow so easy and comprehensible .

  • @MrJoelio7
    @MrJoelio7 7 лет назад

    Quick question. For the factory pattern I did not use "this" keyword for the printPerson function console.log call but I still returned the same results. I also created an animal factory with the same function and did not use the "this" keyword and both my animal and people objects printed just fine. "this" is supposed to define the scope of the properties correct? So is using "this" in the current context just best practice but not required?

    • @Techsithtube
      @Techsithtube  7 лет назад

      you can do it without using this. Its not required. Actually, i have a video on javaScript mixins where i am using latest syntax for factory pattern .

  • @md.imanali9998
    @md.imanali9998 7 лет назад +1

    You are the great tutor!!

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

    Thank you very much for the great tutorial! Short and simple explanation.

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

    Great to learn sir...........I am a learner thanks for providing this stuff!!!!!!

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

    Thanks for share, nice explanation. Just a inside, in the dynamic proto, last example, I think should be peopleDynamicProto.prototype.printPerson instead this.printPerson in the if statement.

    • @ashishkalra4769
      @ashishkalra4769 8 лет назад +2

      +Adalberto Joco :Both will work because on first object creation printPerson has been added to the prototype chain so even if you try to check with this keyword it will give typeof as function.

  • @hal7mar
    @hal7mar 8 лет назад +7

    A constructor name should start with a capital letter

  • @globalentertainment3169
    @globalentertainment3169 7 лет назад +1

    Best explanation ever. Thank you

  • @metime2694
    @metime2694 7 лет назад

    It would be great if you can expain me What is the difference between when I am writing prototype.property / prototype function inside main function or outside main function ?? Becasue by doing both way allow me to access it where I created new object

    • @Techsithtube
      @Techsithtube  7 лет назад

      I would prefer it outside the main function . I have a new series on object oriented JavaScript where i explain the whole concept well. you can check it your.

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

    Nice tutorial. This video is now published on PencilTree.

  • @korneliuspasztor7465
    @korneliuspasztor7465 6 лет назад +2

    U are way better explaining this than my professor, thx man!

  • @trymysolution9831
    @trymysolution9831 6 лет назад

    @techSith can i know what's wrong in this, in this way we can avoid an empty function declaration
    var test = function(){
    test.prototype.insideTest = function(){
    console.log('cool')
    }
    console.log(this)
    }

    • @Techsithtube
      @Techsithtube  6 лет назад

      yes you can do that .
      here is an example
      const test = function() {
      test.prototype.insideTest = function(n) {
      this.n = n;
      }
      }
      const newTest = new test();
      newTest.insideTest(1)
      console.log(newTest)

  • @XD-ci6jl
    @XD-ci6jl 8 лет назад

    Amazing tutorial, you kept it simple all the way throught.

  • @suhasc9418
    @suhasc9418 7 лет назад +5

    Hi techsith,
    I request for a clarification. Thanks to you, I have gained advanced skill set but I really do not know where to apply this. I want to have something created/contributed to a project, that is visible to my potential employers so as to prove my skill. How can I do this online ? Can you please briefly guide us and share your experience as it will be really helpful for most of us. Thank you so much

    • @Techsithtube
      @Techsithtube  7 лет назад +2

      Hi Suhas, application for object creattion patterns is a s following . If you have used angular js you would see use of factories . its basically a library of functions that you can inject into your module and you will have all the factory functions available. the factory function looks something like this.
      app.factory('MyFactory', function () {
      return {
      factoryFunction: function () {
      console.log('hello');
      }
      }
      });
      in the controller of angular app you can use this factory like this
      app.controller('AppController', function (MyFactory) {
      MyFactory.factoryFunction(); // logs 'hello'
      });
      Now services in angular uses constrctor pattern as below
      app.service('MyService', function () {
      this.serviceFunction = function () {
      console.log('hello');
      };
      });
      You can use inject in your app like this
      app.controller('AppController', function (MyService) {
      MyService.serviceFunction(); // logs 'hello'
      });
      Overall if you really want to use these pattern you can create your own project on github
      I would say first create a project, think of something that you would enjoy building and then
      Break it down into functionalities and let me know . I will help you utilize somte of the patterns
      so you would understand.

    • @suhasc9418
      @suhasc9418 7 лет назад +2

      Hi Techsith,
      Thank you so much for the reply. And in general if I have to apply my Javascript skills, Do you think contributing to open-source is the best way or are there other ways too to demonstrate my skills?

    • @svrakata
      @svrakata 7 лет назад +3

      cmon man, be creative, build a website, create database if you want, script some animations or try the coding train with some processing, make simple html game -----> put all in github, link to blog or website and you will be atleast okeish :)

    • @earcandies9677
      @earcandies9677 6 лет назад +2

      Hi i find this reply helpful. I want to build something to put this learning in practice. Can you please give me some examples what i can start building? I would appreciate your help.

    • @kk261293
      @kk261293 6 лет назад

      can you give examples in REACT? as i am not familiar with angular.
      thanks
      kuljeet

  • @DanielWeikert
    @DanielWeikert 7 лет назад

    do I always have to define my functions first before they appear in code even if i do not use them?, e.g console gives me an error function x not defined even though this function would only be executed if i press a button? One more question considering fetching data from web. ajax, fetch or axios, which one should I use. Thanks techsith

    • @Techsithtube
      @Techsithtube  7 лет назад

      Yes you have to define function before you use them even if you are not using athe load time. Fetching data from the we should be done using promises which is the best way. I have a tutorial on promises if you want to check it out. it uses ajax inside.

    • @DanielWeikert
      @DanielWeikert 7 лет назад

      Thanks techsith

  • @cleverdeveloper1042
    @cleverdeveloper1042 7 лет назад

    Everything available explained! Thanks for tutorial

  • @trymysolution9831
    @trymysolution9831 6 лет назад

    @techSith, fantastic ...... No words to say, my sincere request is, can you make a video on Singleton, strategy, modular pattern as well using Class

    • @Techsithtube
      @Techsithtube  6 лет назад

      Here is playlist on object oriented javaScript that also include classes.
      ruclips.net/p/PL7pEw9n3GkoW0ceMeoycg9D00YjPAbtvt

    • @trymysolution9831
      @trymysolution9831 6 лет назад

      Singleton, strategy, modular pattern ???

  • @NaveenKolambage
    @NaveenKolambage 7 лет назад +1

    accent techsith -ALMOST PERFECT! SUPIRI

    • @Techsithtube
      @Techsithtube  7 лет назад +1

      You can look at the latest factory pattern in my JavaScript mixin video. Thanks for watching.

    • @NaveenKolambage
      @NaveenKolambage 7 лет назад

      techsith sure

  • @jcantonelli1
    @jcantonelli1 7 лет назад +1

    Excellent tutorial - thanks for this!

  • @caribbeanman3379
    @caribbeanman3379 8 лет назад +4

    Instead of using the *if* statement in the dynamic prototype example, can we use the *||* operator like so:
    this.printPerson = this.printPerson ||
    PeopleDynamicProto.prototype.printPerson = function(){
    // method code
    };

    • @VENKATBHARADWAJB
      @VENKATBHARADWAJB 6 лет назад

      this might be error prone as someone might say this.printPerson = true;

    • @dheerajmantena3307
      @dheerajmantena3307 6 лет назад +1

      that's way long, simply write:
      _____________________________________________________________
      if(!this.printperson){
      PeopleDynamicProto.prototype.printperson=function(){
      console.log(this.age + this.state + this.weigh);
      };
      }

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

      @@VENKATBHARADWAJB JavaScript is dynamically typed because a coder knows his own codebase, a smart coder uses great variable names that make understanding it's value or use easy, and you should read what a function and it's parameters do before tossing in data and calling it. If you do want that level of control you can write error handling logic, or use TypeScript.

  • @jenniferbrenner384
    @jenniferbrenner384 7 лет назад

    Great, helpful video. Thanks!

  • @abilashr1958
    @abilashr1958 7 лет назад

    Awesome and Crystal...

  • @thomashodges841
    @thomashodges841 7 лет назад

    Thank you! I was stuck on a textbook on NodeJS because it was using the dynamic prototype pattern and assuming the reader had knowledge of this pattern.
    Is there any way to combine this with the Revealing Module Pattern so as to have restricted access to my parameters but keep my methods out of the individual instantiations and in a prototype?

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

    very nice video! Question, both the Construct and Factory patterns have the redundant problem right? Thanks!

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

      Can you explain abit what you mean by redundant here?

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

      yes. When you talk about using prototype because the problems of the Construct pattern you said that every time you create an object, the properties and methods are created again and again, wanted to know if the sames happen with the Factory pattern

  • @iffipifi1
    @iffipifi1 7 лет назад +3

    Best explanation Ever. You are my Guru

  • @33aggi
    @33aggi 8 лет назад

    wow! excellent tutorial

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

    Thanks,very very good tutorial.....

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

    Great tutorial, congrats on 5k subs. (5001 now :) )

  • @keren1978
    @keren1978 6 лет назад +1

    Thank you for the content. It's helpful and clear.

  • @SAURABHKUMARSUMAN
    @SAURABHKUMARSUMAN 6 лет назад

    can we add additional property to object in in dynamic prototyping ?

    • @Techsithtube
      @Techsithtube  6 лет назад

      Yes you could add additional property whenever you like.

  • @amundsenq1835
    @amundsenq1835 7 лет назад +1

    Hi techsith, i found an another way to create multiple methods in prototype from MDN,
    function MyObject(nickname, message) {
    this.nickname = nickname.toString();
    this.message = message.toString();
    }
    (function() {
    this.getName = function() {
    return this.nickname;
    };
    this.getMessage = function() {
    return this.message;
    };
    }).call(MyObject.prototype);
    Using .call() method to make more concise syntax.

    • @Techsithtube
      @Techsithtube  7 лет назад

      Yes this is also good functional programming trick .

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

    Prototype creates instances for the object? or they will share the same memory. if they share same memory then all the objects will have same value. So tell me how it works?

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

      for the properties , for example, x.prototype.prop = 1;
      This would become like a static (shared) property. Only do this if you want that behaviour.
      However for function it makes more sense. x.prototype.myFunct = function(){};
      this you want shared. and not attach with every object .

  • @abhijitjagtap2964
    @abhijitjagtap2964 6 лет назад

    the tutorial really helpful but I am little confused between contructor pattern and dynamic prototype pattern, both works like same only we put if condition to avoid overriding prototype function but object works like constructor pattern means object already copied function in its own property, so how it better than prototype pattern?

    • @Techsithtube
      @Techsithtube  6 лет назад

      Dynamic prototype is consider as improvement to the regular constructor pattern as you can see in the example. And overall dynamic prototype is bit better than prototype pattern as it allows user to set the prototype dynamically. I would suggest avoiding the regular constructor pattern. Also, now you can use classes.

  • @dipakchavda5763
    @dipakchavda5763 6 лет назад

    It is really nice video but when we talk about create an custom architecture of NodeJS what should we do? I required to create an micro-service based custom architecture, so I bit confused that what should I do? which design pattern I should use to construct an architecture of an application? can you give me suggestion or guidelines?

    • @Techsithtube
      @Techsithtube  6 лет назад

      what is the requirement? I mean if you show me one specific requirement i can make suggestions.

    • @dipakchavda5763
      @dipakchavda5763 6 лет назад

      Actually there is no specific requirement in an application. I would say I have an idea but I don't know how to implement this structure in application. Idea is like that, it has an interface with some methods and which is like init() and it must implements in every class, where it inherits and some common libraries which my use in application anywhere. So this is basic requirements. I know JavaScript and NodeJS and having 7 years of experience in programming but I bit confused that how do I start and create application boiler plate with core JavaScript to create an application structure. I know very well Express framework, but I would like to create robust structure with object oriented programming in NodeJS with JavaScript which will help me to in future application. So I am very thankful to you if you guide me.

  • @gopal16081985
    @gopal16081985 7 лет назад

    Hello ,Excellent tutorial ,could you please provide more info about memory management and more about performance improvements and more inside stuff like how engine interprets the Js thanks a lot

    • @Techsithtube
      @Techsithtube  7 лет назад

      I was thinking of such tutorial but i was not sure about the audience. Good to know that you are intrested to know . i will think of some technique to improve performance and some dos and donts in JS. Thanks for watching!

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

    waiting for the day when you start making express and node.js tutorials , by the way this one was awesome tutorial!

    • @Techsithtube
      @Techsithtube  8 лет назад +1

      +saurabh vyas That is my plan next. I will create node.js tutorials. thanks for the suggestion.

  • @judeleon8485
    @judeleon8485 2 года назад

    Excellent explanation

  • @ifeanyinnaemego
    @ifeanyinnaemego 7 лет назад +1

    thanks for such a wonderful tutorial. Are we to expect more???

    • @Techsithtube
      @Techsithtube  7 лет назад

      Actually I have a series on Object Oriented JavaScript . Its one of my playlist , Please check it out. . And if you cant find what you looking for , let me know I will make a video on that subject. Thanks for watching.

  • @expukpuk
    @expukpuk 6 лет назад

    Thanks mate, informative lesson.

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

    Quick question with factory and constructor method... Didnt we use 'new' while declaring our Factory method by assigning it to {} ? Isn't this same as doing a constructor pattern but just using new implicitly ? Thanks for the informative videos though!

  • @earcandies9677
    @earcandies9677 6 лет назад

    I have a question, towards the end of the video when explaining "if" condition in Dynamic Prototype Pattern, you say that the propose of if condition is to check if printPerson function has been created or not. (as per my understanding) it will be created only once in a shared space when we create the first object. after that each time we create an object, this function will not be created (if condition will filter it out). This is the background
    question>>How is this different from Prototype Pattern? I am not talking about whole pattern, i am just comparing printPerson function and logic of using if condition in Dynamic Prototype Pattern but not in Prototype Pattern. in Prototype Pattern (using key word "prototype") when an object is created the function printPerson is kept in shared space once and all the following objects will have access the function (no duplication of function is there). So whats the logic of using If condition in Dynamic Prototype Pattern if you are using for example people. prototype.printPerson (using "prototype" key word as you did in Pattern Prototype) inside If Condition?

    • @Techsithtube
      @Techsithtube  6 лет назад

      Dynamic Prototype Pattern makes sure that you define function only one time and inside the constructor function and not outside. this way you have to check if it's not previously defined then you define it. It's important as you can define the prototype method outside the constructor function.

  • @monkeymagic2385
    @monkeymagic2385 7 лет назад

    Are you able to provide examples of when one pattern should/shouldn't be used over another? Each of these patterns can acheive the same end result, but I'm assuming there are reaosns at an engineering level (performance/memory reasons) why these different pattens exist.

  • @tushar000001
    @tushar000001 8 лет назад +1

    Really nice video... Just want to know what is the difference between constructor pattern & prototype pattern. Why should one prefer prototype over constructor pattern?

    • @Techsithtube
      @Techsithtube  8 лет назад +2

      I have a video on prototype inheritance. there are two parts to it. you should watch it to understand it. But to explain in short. in prototype inheritance, the objects are lighter since the methods are defined in the prototype.

  • @ramfartare2677
    @ramfartare2677 6 лет назад

    Great Tutorial Very Clear.Thank You
    How to improve Programming logic skill ?

    • @Techsithtube
      @Techsithtube  6 лет назад

      To improve Programming Logic Skill you have to practice a lot. I also created a video that might help. ruclips.net/video/X1omyGA67Vg/видео.html

  • @simpsot_
    @simpsot_ 7 лет назад +2

    very very clear and easy to follow along...7/7 (subbed)

  • @SimpleKaban
    @SimpleKaban 8 лет назад +2

    Dude, your videos are cool, but please do double click to higlight the word you want to copy/past. I cry when you do it with mouse drugging, it's too slow!

  • @thiruthiru1
    @thiruthiru1 9 лет назад

    Very well explained. Keep it up.

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

    In the beginning of the video about "Factory Function" why would you use the (.temp) object rather than use the (.this) function and also what is the significance of the .temp object?

    • @Techsithtube
      @Techsithtube  8 лет назад +1

      using this makes it a construction pattern . If you want to use Factory Pattern you have to build a temp object inside and return . .

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

      Oh gotcha! Thanks!

  • @gabycampagna4157
    @gabycampagna4157 7 лет назад +1

    Great tutorial!

  • @shadabzilani5866
    @shadabzilani5866 7 лет назад +6

    please explain singleton , moduler pattern and observer pattern in js.

    • @Techsithtube
      @Techsithtube  7 лет назад +5

      Sure I will make tutorials on those topics.

    • @jainshilpi3
      @jainshilpi3 6 лет назад +1

      please make the above video -singleton , moduler pattern and observer pattern in js.

  • @olawalemoses8958
    @olawalemoses8958 7 лет назад +1

    Thanks techsit I grabbed alot.

  • @kashyapbhansali7
    @kashyapbhansali7 7 лет назад +1

    Thanks a lot! Great tutorial ! :)

  • @sreid70
    @sreid70 7 лет назад +1

    Great video. Thanks

  • @H3000-v7i
    @H3000-v7i 6 лет назад

    I think this is a better way for the last one....
    var peopleDynamicProto = function(name, age, state){
    this.age = age;
    this.name = name;
    this.state = state;
    };
    peopleDynamicProto.prototype.printPerson = function(){
    console.log(this.name+ ", " + this.age+ ", "+ this.state)
    };

  • @sahilarora7186
    @sahilarora7186 4 года назад

    Great work sir