Sunday, August 7, 2016

Summer Research Week 5 Homework

Video Notes

Object Factory, thenewboston 11


  • to create a new object
    • must give them a function that returns
  • an object that makes other objects
  • each have their own information instead of sharing

In this video, we learned about giving each variable unique characteristics instead of having all the variables share everything. The video was very concise about it and we understood the information. We think that this could be useful in the drone project because every movement in the drone is different.


Core Modules, thenewboston 12
  • there are a lot of core modules 
    • modules that are already in node.js
  • fs
    • file system module
    • read, write, and delete files
      • to make one fs.writeFileSync
        • path = file name
        • data = content
        • options = optional
      • console.log(variable.readileSync(text).toString
        • reads and logs it out
  • whenever you use core module
    • do not include path
      • makes node.js find it easier
    • variable = module to make it simple 
  • path
    • normalizes slashes depending on OS
    • console.log(path.normalize(variable))
    • can also fix errors
      • usage: web servers
    • console.log(path.dirname(variable))
      • gives the directory of the file
    • console.log (path.basename(variable))
      • gives the base name
    • console.log (path.extname(variable))
      • what type of file
  • setInterval 
    • repeats continuously for the set amount of time
    • put consolelog inside to have a message repeat in a certain interval
    • different from timeout
  • consolelog(_dirname)
    • prints out the directory name of whatever file is currently calling the code
  • consolelog(_filename)
    • prints out the entire file name of whatever file is currently calling the code

In this video, there was a lot of information to take in. This part of the node.js tutorial by thenewboston introduced us to Core Modules; this built onto the information we learned from the previous week. There are many useful, built-in modules that help us with our coding experience; for example, the setInterval could be extremely beneficial for us because we can have it record the condition of the drone continuously. 


Creating a Basic Server, thenewboston 13
  • http module already built in
  • http variable.createServer
    • when connect to server, server has to listen to request
      • have a port number
  • function onRequest (request, response)
    • request
      • from the connector
      • can see what they were doing or looking at
    • response
      • tells them the connectivity and such
      • .writeHead
      • .write gives them a writing
      • .end tells the writing ends
    • 200 status code is good
    • 404 means that something did not go well
  • browser has two requests
    • whatever page is looking for
    • also requests for the favicon

In this video, we learned about creating a server. We understood the content in the video, but we did not really see how it connected with our project. This basically taught us how to make a website which could be helpful in life, but we did not see how it would help us.


Simple Web File Server, thenewboston 14
  • require fs module
  • require http
  • GET
    • standard way to connect to server
  • / = homepage
  • text plain = plain string of text
  • text html = html file
  • fs.createReadStream
    • read the file
    • .pipe
      • put out the response object
  • else
    • if something is not right

In this video, we understood more about creating a server. Although this might not directly relate to our project, we thought that these tutorials helped our brains understand coding much more. Since these were topics that we were not familiar with, we had to keep rewinding the video to understand what the code did and why does the code work that way.


Connect, thenewboston 15
  • terminal
    • npm install connect
  • http.createServer
  • goes a certain order by doing another method in the "stack"
    • app.use(variable)
    • doing next will allow us to go to the next one one the list
  • function doFirst (request, response, next)
  • you can organize the path based on the requests received
    • app.use ('/variable,variable)
  • can see what webpage people are going to use and will lead them to it

In this video, we learned about Connect. We found this very helpful because we could organize the code according to the order it will occur. This is useful because it could prioritize more important matters first when working with the drone. We comprehend the material, but we thought that it was still confusing because we had to work with so many different variables. With Connect, we had to make sure everything was aligned properly. 


Express, thenewboston 16
  • file -> new project
    • node.js and NPM
      • express APP
  • template
    • how to write plain HTML templates
    • EJS
  • bin
    • www
      • go to the port inside (3000)
  • idea
    • do not touch
  • in express, www file is the start up script
    • app js is the core
    • node_module
      • for any other modules 
  • anything that users can use is going to public
  • brains of each page is routes
    • index
    • user
  • views
    • html for each page

In this video, we had a lot of content to take in similar to the 12th part of the node.js tutorial. This ws a brand new concept that we had to take in. There was a lot of information thrown at us and we started to get confused, but thenewboston explained it well. He briefly told us what each directory meant and how it affected Express as a whole. We were less confused by the end of the video, but we were curious about each directory. 


Handling User Requests, thenewboston 17
  • app.use
    • tells the system what happens
  • same idea as Connect
  • send the variable to a certain page
    • goes to the brain and it sends out the information

In this video, there were not that many notes to take down because all of the variables were explained briefly. This video basically added onto the last one by breaking down the function of the directories. It also made us recall the information from the fifteenth video. It shows how one directory links with the other ones. 


Understanding app.js, thenewboston 18
  • logger
    • module is used for logging out information in the terminal
  • cookieParser
    • handling cookies
  • bodyParser
    • parse text body or Jason body
  • gives a detailed information of how something is wrong
    • error handler
  • during development
    • want to stack up the errors
  • during actual production
    • hide the errors

In this video, the information was explained more thoroughly and there was nothing much to really take notes on. We learned about why the error handler was broken into two parts and we were fascinated about it because we never knew that web designers did this. 


EJS, thenewboston 19
  • html or the view for the webpage
  • EJS
    • embedded javascript
    • html that javascript can be plugged into
  • equal sign are for variables
  • no equal sign are for plain javascript
  • you can attach variables and extend it into the ejs
    • for example variable "name" can be Bob and if "name" was written in ejs, then Bob will be written

In this video, we learned many new things. HTML was the view for the webpage, EJS is Embedded Javascript and it is basically HTML that JavaScript can be plugged into, and we learned two crucial pieces of information. Firstly, when we type in EJS, we need equal signs for variables and we do not include equal signs for plain JavaScript. Secondly, we can tidy up the code and make everything less intimidating by incorporating variables in EJS and we can use this variable again in different files. This would reduce the wordiness and it makes everything more neat.


Adding More Pages, thenewboston 20
  • add a new directory to views
    • inside new directory, add new file
  • when add a new file, then add new file in route
  • separate using |
  • on homepage, include the navigation 
  • in app.js we need to add all the other pages
  • by separating everything, we don't need to keep adjusting
  • new view, new route, adjust app.js 

In this video, we learned more about organizing a web page. Although this isn't exactly what we are going to do in our Advanced STEM Research project, we found it interesting to learn about. Since we are going on different websites daily, the coding behind it was very intriguing. The material was summed up well and it was presented in a way that was simple to understand like most of thenewboston's video.


Overall, I think that we learned a lot more about coding this week than any other week. Even though most of the information will not be applied in our project, we found it entertaining to learn about because the YouTuber seemed like a pretty cool guy. He presented the material in a simple and education manner that even beginners could comprehend. We were also reviewing the code that was done last year to see if we improved our knowledge.

No comments:

Post a Comment