Wednesday, January 22, 2020

BlogPost_303

  • If a user attempts to create a resource that already exists—for example, an email address that’s already registered—what HTTP status code would you return?
    • 409. The HTTP 409 Conflict response status code indicates a request conflict with current state of the server. ... For example, you may get a 409 response when uploading a file which is older than the one already on the server resulting in a version control conflict.
  • Consider a responsive site design that requires a full-width image in all responsive states. What would be the correct way to code this to ensure the page loads the smallest image required to fill the space?
    • Have a set of sizes available on your server (say 350px, 700px, 1000px, 1500px, 2000px, 4000px) and use srcset attribute of image tag. Your browser will automatically load the best one. 
    • If you need find grained control over what screen size loads what, you can also use media queries in CSS and put image in background of a full length placeholder div instead of using an img ray
  • When should you npm and when yarn?
    • Yarn when you want to want to lock dependencies to their specific versions. Yarn has the power to perform multiple installation steps at once, which speeds up the process. Npm goes sequencially. Yarn is normally faster to install. Yarn only installs dependencies from your yarn.lock so it's considered more secure. Since Yarn is supported by some of the world's largest tech companies, bugs are identified and taken care of fairly quickly. Using npm and yarn together can create some problems. Yarn is slowly overtaking npm. 
  • How can you make sure your dependencies are safe?
    • When writing Node.js applications, ending up with hundreds or even thousands of dependencies can easily happen. For example, if you depend on Express, you depend on 27 other modules directly, and of course on those dependencies' as well, so manually checking all of them is not an option!
      The only option is to automate the update / security audit of your dependencies. For that there are free and paid options:
      • npm outdated
      • Trace by RisingStack
      • NSP
      • GreenKeeper
      • Snyk
    • First, it's important to do our homework before installing a package.
      Read the package's page on npmjs.com and look at who published the package, the number of versions and the number of weekly downloads. If these numbers are very low, I would pass or definitely inspect the source code.
      Another thing, to pay attention is when you type the package name. Typo squatting is possible and there are published packages which have names close to popular packages.
      In terms of how secure is NPM (the registry), they do periodic penetration testing and outgoing code reviews. Also, they report vulnerabilities to package authors and handle vulnerabilities reports from other users. But, it's a continuous fight against spammers, malware, etc.
  • What are the differences between CHAR and VARCHAR data types? (MySQL)
    • A CHAR field is a fixed length, and VARCHAR is a variable length field.
      This means that the storage requirements are different - a CHAR always takes the same amount of space regardless of what you store, whereas the storage requirements for a VARCHAR vary depending on the specific string stored.
  • How else can the JavaScript code below be written using Node.Js to produce the same output?
    • console.log("first");
      setTimeout(function() {
          console.log("second");
      }, 0);
      console.log("third");
      
      // Output:
      
      // first
      // third
      // second
    • console.log("first");
      setImmediate(function(){
          console.log("second");
      });
      console.log("third");

Sunday, January 19, 2020

BlogPost_302

  • What do you find challenging about coding?
    • Keeping track, mentally, of where everything is. It starts to get a bit overwhelming when you have a few projects open and you want to keep track of where everything is. Then whenever you make a change, since something you code can be super long, its not easy to know immediately every part that's being affected by your new change. That is frustrating because if you have been making changes and saving your file... at some point you can get lost in a tangle web of bad choices that you thought were good choices to make your code better but now you can't even go back to where your code worked. So I find it challenging to keep track, mentally, of where everything is and what parts of the code are being affected by any new change made.
  • Talk about a project that disappointed you. What would you change?
    • I think this project about the databases disappointed me. The ExpressJS continuation. I wanted to finish it by Sunday and had tutoring scheduled for Saturday but my tutor cancelled me last minute because he said he was sick with the flu. I attempted to do the thing myself and was able to complete up until the beginning of part 3. 
    • I would not use part 3 of the project. I feel it is an extra layer of complication that's not necessary. Maybe I don't understand it fully but I just don't get why the functions have to be recoded in the controller files if they already work fine in the first place. I'm disappointed in seeing all those confusing rearrangements.
    • If I were an expressjs coder I would code a script to autogenerate the routes and controller files and move the code that needs to be moved and generate the code that needs to be generated. 
  • List three key things to consider when coding with SEO in mind.
    • Metatags for the search crawler to be able to find you.
    • The HTML Accessibility.
    • Links
    • Page loading speed
    • Secure SSL website
  • List five or more ways you could optimize a website to be as efficient and scalable as possible.
    • Have the website's separated from the server code.
    • Have all your files hosted in a separate server.
    • Be able to replicate or duplicate your servers and keep the connections instantaneously.
    • Reduce the number of plugins.
    • Don't use ads.
    • Minimize the number of javascript and css files.

Friday, January 10, 2020

BlogPost_301

  • How do you organize your code? What are some suggestions you find on the web?
    • I normally just organize it in so far it is in the order I have been coding it. I leave notes above each chunk of code to know what does what. I didn´t know I could have multiple javascript files until I watched the video. I´m not sure yet how I could do that on a website without npm.
  • Can you describe your workflow when you create a web page or web app?
    • I think about what I want to do for a while. I simulate a few options in my head. If they don´t work or I can´t see how to make it I keep thinking about it. At some point I understand how to divide its parts and then just start coding the parts from the ground up. I do know about different approaches to this but i´ve been lazy to use them. Something like SCRUM and Agile.
  • You can’t work out how to solve a coding problem, where do you find the answer? Why? How do you know?
    • It depends on how difficult it is. If its something I don´t know about and it´ll take me too much time to learn and implement I tend to look for another person who actually knows about it. If it´s something that will not take too long then I research it. If research goes beyond my estimated time and there´s no progress being made... I ask for help. 
  • What problems have you solved that didn’t involve you coding?
    • I´ve solved a few problems regarding databases using the help of a friend who knows how to use them. I´m not sure. This question is too vague. I can´t think of examples off the top of my head right now. What do you mean by problems? coding problems? If it´s coding problems then asking for help usually gets the job done. Another option has been looking for YouTube videos and hoping that there´s a similar problem there where I can see a path forward. I´ve been watching the Wes Bos new javascript course and it´s helped me identify a lot of stuff on code that I had no idea what it was before. 
  • Talk about your preferred development environment. (What IDE or text editor they enjoy, and why?
    • I really like VScode because I´m already used to it. I´ve tried different editors and they usually involve the user having to do a lot more steps to get somewhere and do something. I think VScode has been created with the developer who doesn´t want to waste time in the details in mind. That´s really good. 
  • How are you keeping up with the latest developments in web development?
    • Well... being informed is one thing but actually knowing how to implement everything is another. I´m aware of different things going on but I´m not capable of implementing them. I follow different people on instagram and youtube who show news about these subjects but it´s not all something i´m really interested in enough to learn it right away. I tend to wait a bit for things to settle down in order to see if they´re really going to stay or not. Most new things disappear very quickly and it´s not worth wasting time on them(in my opinion).