Tuesday, July 26, 2016

Notes on Video #4 Tutorial by thenewboston

Watching this video, there were many confusing aspects but the video mainly involved the handling of multiple requests. Watching the video, it was simple to understand that the increased use of "NodeJS" code is mainly because of its efficiency and speed. This type of code is used mainly in real-time web applications and social networking applications for handling multiple requests. In the video, some key points were...

  • the setTimeout command - this command basically tells and scheduling a bit of code to run in 5 seconds. This command is usually instantaneous. 
  • console.log is a function mainly used to print a certain text, and usually can be linked to a specific function, if specified.
  • you can also place functions in the process of another function, and run a bit of code

Simply think of this as a situation involving a waitress, a cook, and the customers. The customers are requesting for some data from the database, and the database basically represents the cook. The waitress will take the request, give it to the chef and individually do this to each customer. This would however, take a long period of time. Instead, using this type of code, including the setTimeout command, the waiter which practically represents the node.js code, will take all the requests simultaneously and then return the orders back from the database in a set period of time from the setTimeout command. Basically instead of taking one order at a time and waiting in between to return the order, it will instead take each request and give it to the chef to satisfy each request. This makes the code quicker and more efficient. 

Note: This example is based of the example the tutorial gave. 

No comments:

Post a Comment