Section 1

Preview this deck

client vs server

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (68)

Section 1

(50 cards)

client vs server

Front

client side - sends HTTP request, renders response data server side - handles HTTP request, generates/sends response

Back

API

Front

Application Programming Interface is offered by a server for communication with a client app. A client computer program can send instructions to the server and get data from the server by sending requests to various URL endpoints that form the API.

Back

http core library

Front

how Node runs an HTTP server and supports backend applications.

Back

the event loop

Front

A system to sequentially process tasks. makes callbacks possible Node processes events sequentially from the event queue which is just a queue of events (function calls, etc.). If the event is asynchronous, Node asks the operating system to notify it when the event is ready for processing. Meanwhile, it continues processing other events in the queue. The thread pool is a collection of technologies that help execute events, such as accessing the file system.

Back

URI

Front

Uniform Resource Identifier - specifies how to access a resource on the Internet

Back

***

Front

Back

URL

Front

Uniform Resource Locator; a location or address identifying where documents can be found on the Internet; a Web address

Back

shell

Front

A user interface for access to an operating system's services.

Back

HTTP core library

Front

how Node runs an HTTP server and supports backend applications.

Back

nodemon

Front

nodemon watches the files in the directory it's running in, and, if any data changes will automatically restart your node application.

Back

How do you import a module?

Front

require();

Back

Server-Side JavaScript

Front

runs in Node.js process, doesn't render anything, handles http requests, sends responses, has no window of document objects, does not interface with HTML or DOM, no selector etc; can make direct HTTP resuests, uses modules to split code into files

Back

client-side javascript

Front

runs in a browser process, renders the page, handles user interactions, makes requests, has window and document objects, interfaces with HTML and DOM, uses AJAX to make HTTP requests, uses script tags to split code into files

Back

node core libraries

Front

fs, http, node modules

Back

dotenv

Front

a Node package that assists us with handling environment variables for our development environment. When dotenv is configured, it will look for a file called .env in the root of the application and load those variables into memory.

Back

testing code

Front

used to state expectations production code will meet and raises errors when stated expectations are not met. two primary reasons to write test code are 1) to ensure production code does what it's intended to do 2) to ensure that production code doesn't break with you refactor it.

Back

Modules

Front

A set of functions you want to include in your application a self-contained component that is intended to perform a function and be portable enough to swap in and out as needed. The module has all it needs to perform this function. independent, interchangeable pieces of code that contain everything necessary to execute one separate aspect of the desired functionality. This principle in Computer Science is called Separation of Concerns. Simply put, modules are either packages or libraries that you can import and use in your code. portable, encapsulated and reusable

Back

Unix Philosophy

Front

The Unix philosophy is a guideline for minimalist, modular software development. Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features. Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don't insist on interactive input. Design and build software, even operating systems, to be tried early, ideally within weeks. Don't hesitate to throw away the clumsy parts and rebuild them. Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you've finished using them.

Back

Non-blocking

Front

Considered asynchronous

Back

types of functions

Front

function declaration, function expression, shorthand, aarow, generator, new function

Back

template literals

Front

Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They allow for both multiline strings and string interpolation. console.log(`foo bar`); // foo // bar var foo = 'bar'; console.log(`Let's meet at the ${foo}`); // Let's meet at the bar Template literals are enclosed by the back-tick (` `) (grave accent) character instead of double or single quotes. Template literals can contain placeholders. These are indicated by the dollar sign and curly braces (${expression}). The expressions in the placeholders and the text between the back-ticks (` `) get passed to a function. The default function just concatenates the parts into a single string. If there is an expression preceding the template literal (tag here), this is called a "tagged template". In that case, the tag expression (usually a function) gets called with the template literal, which you can then manipulate before outputting. To escape a back-tick in a template literal, put a backslash \ before the back-tick.

Back

Asynchronous

Front

or non-blocking, means your code does not wait for the current line to execute before moving on to run the next line.

Back

callback functions

Front

A function called after another function has finished executing. The callback function is called once a particular task has finished. When an asynchronous background operation such as reading a directory finishes executing, Node needs some way to communicate this back to the program(callback). made possible by the event loop

Back

exports

Front

A reference to module.exports. Any reassignment of exports will not be available outside of the module exports is a reference to module.exports and cannot reassign the object module.exports. You may use either module.exports or exports within your Node app. If you want your module to be a specific object type, use module.exports. Otherwise, use exports. Using exports is recommended unless you are planning on having your module be a specific object type.module.exports and cannot reassign the object module.exports. You may use either module.exports or exports within your Node app. If you want your module to be a specific object type, use module.exports. Otherwise, use exports. Using exports is recommended unless you are planning on having your module be a specific object type.

Back

utf8

Front

A Unicode-based encoding such as UTF-8 can support many languages and can accommodate pages and forms in any mixture of those languages. Its use also eliminates the need for server-side logic to individually determine the character encoding for each page served or each incoming form submission.

Back

streams

Front

Collections of data read as input as well as outputted.

Back

views

Front

complete HTML documents

Back

What JavaScript statement do you use to export a module?

Front

module.exports

Back

Why is using exports recommended?

Front

exports is recommended because it will not overwrite whatever you have assigned to module.exports because exports is a reference to module.exports and cannot reassign the actual object module.exports. exports is recommended unless you are trying to make module be a specific object type

Back

Why is the fs core module important for Node development?

Front

Because it allows access to the file system through code(aka programmatically)

Back

What is the difference between readdirSync and readdir?

Front

readdirSync is synchronous and readdir is asynchronous. The former will run without letting anything else run before it is finished, while the latter will let other things run while it's running

Back

Synchronous

Front

or blocking, means that your code runs in sequential order. The program waits for the line of code to finish executing before moving on to the next line of code.

Back

partials

Front

pieces of reusable HTML components meant to be included in our views as needed

Back

how node unit testing works**

Front

You can think of tests as safeguards for the applications you are building. They will run not just on your local machine, but also on the CI services so that failing builds won't get pushed to production systems. We write unit tests to see if a given module (unit) works. All the dependencies are stubbed, meaning we are providing fake dependencies for a module. Each unit test has the following structure: Test setup Calling the tested method Asserting

Back

node is

Front

a javascript runtime built on chrome's V8 javascript engine

Back

commonJs modules

Front

With client-side code, we access other libraries by including them in our HTML via a script tag. Since our server-side code doesn't use HTML files, we need another way to access and include external libraries. CommonJS was created to solve this issue, and Node has adopted it as a core library. module.exports = {library here}

Back

What is the main difference between exports and module.exports?

Front

exports is not returned by require() and is just a convenience variable so module authors can write less code. module.exports is the object reference that gets returned from.

Back

HTTP

Front

Hyper Text Transfer Protocol, is a set of rules used to transfer files from a Web server onto a browser in order to view a Web page that is on the Internet.

Back

What is the event loop and how does it handle asynchronous requests?

Front

The event loop is the order in which the calls get processed. Like it will take an asynchronous task from the event queue and run it, then go on to the next one or it will take a synchronous task and wait until it's notified that the task is finished to go back to the event queue

Back

Blocking

Front

when the execution of additional JavaScript code must wait until a previous operation finishes executing. All blocking methods execute synchronously, but not all synchronous methods are blocking.

Back

Why are modules used?

Front

Because they are already built in libraries without any installation.

Back

what is npm and what does it do

Front

Npm is the node.js package manager and we use it in the command line as a tool to install node packages

Back

TDD

Front

test driven development - the process of writing test before writing production code.

Back

fs

Front

node's built in module(short for file system) way to access the file system through code

Back

CommonJS

Front

With client-side code, we access other libraries by including them in our HTML via a script tag. Since our server-side code doesn't use HTML files, we need another way to access and include external libraries. CommonJS was created to solve this issue, and Node has adopted it as a core library.

Back

CRUD

Front

create, read, update, delete

Back

What is the difference between sync and non-sync methods in the fs module?

Front

Sync is synchronous or non-blocking and means that the code will run in sequential order waiting for the previous code to finish executing before moving on. Non-sync is asychronous meaning that it doesn't wait for the current line of code to finish running before executing the next line.

Back

MVC

Front

Model View Controller MVC pattern allows for your application to have a separation of concerns, allowing specific sections of your application to be in charge of specific functionality. Model - consists of the data structures needed to store information and the methods used to interface with the data layer of the application. View - controls everything a user sees and is handled by a view engine which takes dynamic content, replaces that content with placeholders inside of an HTML file, and then sends the final HTML to the client. Controller - handles incoming requests from the client. It will interact with the model to move data in and out of the database and the view.

Back

pipes

Front

A way to pass information from one process to another.

Back

What kind of information does package.json hold?

Front

Key value pairs that communicate to npm how a node application is structured a file that communicates to npm how your application is structured, where all your dependencies are

Back

Section 2

(18 cards)

How do we access data returned from Node's asynchronous functions?

Front

With callback functions. Node has asynchronous functions that prevent blocking code by providing a callback function. The callback function is called at the completion of a given task. Callback functions make Node highly scalable, as it can process a high number of requests without waiting for any function to return a result.

Back

module.exports

Front

The variable that gets returned from require(). It is an empty object by default, and it can be reassigned to anything. module.exports is the object returned from require(). It is an empty object by default, and it can be reassigned to anything. As an empty object, we can add methods and variables to it directly. We can rewrite our module from above, adding the methods directly to the module.exports object:

Back

Which function is used to import modules?

Front

require The require function loads the contents of a module and allows them to be used outside of the module.

Back

how do you create a web server

Front

http.createServer()

Back

What is the difference between synchronous and asynchronous methods of the fs module?

Front

Synchronous code is executed one statement after the other while asynchronous code can execute out of order. Synchronous code blocks the event loop while asynchronous code does not. Synchronous code can be blocking or non-blocking while asynchronous code is always non-blocking. Every method in the fs module has a synchronous as well as an asynchronous form. Asynchronous methods accept error-first callback functions with the signature function(err, data). Asynchronous methods are preferred to synchronous methods because they are always non-blocking.

Back

Which npm command can be used to create a package.json file?

Front

npm init npm install installs dependencies in the local node_modules folder. By default, npm install will install all modules listed as dependencies in a package.json folder

Back

What is blocking code?

Front

Code that halts an application until it has finished executing. If an application has to wait for some operation to finish executing in order to continue further, then the code responsible for the waiting is known as blocking code.

Back

high cohesion, loose coupling

Front

highly cohesive - the attributes and methods are aligned towards doing things in the same domain. loosely coupled - each component should depend on other components as little as possible. A component depends on another component when it is required inside of it.

Back

Middleware

Front

Several different types of software that sit between and provide connectivity for two or more software applications

Back

advantages of tdd

Front

We only write the production code needed to pass a test. This leads to a leaner and more efficient codebase because you only code what you need, nothing more and nothing less. Test-Driven Development allows developers to segment problems into small and testable steps. Testing early and often allows developers to catch bugs earlier, preventing more expensive problems later when the codebase is large and hard to navigate. Writing tests for code that doesn't exist can produce a flow state. Writing tests before writing production code can systematize your thought process, forcing you to be more explicit about how a function or page should behave.

Back

What is Node.js?

Front

A server-side JavaScript framework. Node.js is a server-side runtime environment built on Google's V8 JavaScript Engine. It is used to build scalable web applications.

Back

What is the difference between client-side and server-side JavaScript?

Front

Client-side means that the JavaScript code is run on the browser while server-side means the JavaScript code is run on the server serving web pages. Client-side means that the JavaScript code is run on the client machine, or in other words, the browser. Meanwhile, server-side JavaScript runs on the server. Client-side components can include HTML and CSS while server-side components include Node.js.

Back

What is the fs module?

Front

A module that provides methods to perform operations on a file system. The fs module provides a simple file system module to perform file-related operations. The module is comprised of synchronous and asynchronous functions. For example, the readFile() function is an asynchronous function to read file content from a specified path and readFileSync() is a synchronous function to read file content from a specified path.

Back

Walk through of TDD

Front

1)Write a failing test for production functionality that does not exist.Ensure that the test actually fails. Doing this verifies two aspects of the test: first, it demonstrates that the new spec does not pass with the existing code you've written, saving you from writing unnecessary code; second, it precludes the possibility that your test always passes, which could be an indication of a poorly-written test. 2)Create the production functionality such that the test passes. 3)Refactor the production code to make it cleaner and more sustainable. With a well-written test, you can refactor production code with the confidence that you will not break the application. If you refactor your code in such a way that breaks the application, your test will fail, and you will know to fix the problem that caused the failure.

Back

ORM

Front

Object Relational Mapping similar to a translation service, in that it provides a way for developers to manipulate a database using another language besides SQL. useful because its portability means you can write the schema (database structure) and the ORM handles generating the correct statements required by the database management system. allows you to use the language of your choice and have it automatically translated into SQL. CONS - an abstraction on top of your database. This abstraction means it is much slower to execute the same command through your ORM as compared to pure SQL. You are also limited to whatever methods are defined by the ORM, which could potentially be unable to write complex queries that would be more performant if written in SQL.

Back

BDD

Front

Behavior Driven Development Behavior-Driven Development extends Test-Driven Development with behavioral specifications. This extension means the tests end up focusing more on the behavior your code should be implementing. The tests also end up reading more like a sentence coming out of a user story. This helps integrate acceptance criteria into testable chunks that everyone in the team can understand.

Back

BDD Principles

Front

1)Respect object limits: When testing an object, try not to test any other objects, even if they're related. Narrow the scope of the test to be as small and self-contained as possible. 2)Don't test "how," test "what": We want to test what a method returns, not how it returns it. The internal implementation of a method is subjective, and while we believe in idioms and programming style, it is not the test's job to assess those things - only to assess what the code returns. 3)Write DRY tests: Wherever possible, avoid repetition in tests, just like production code. 4)Test early and often: Tests function as our safety net, but they can't help us if we don't use them. At a minimum, we'll want to run our specs before each commit. Running tests before each commit will allow us to reduce bugs proactively before we add them to the codebase.

Back

What information does the package.json file contain?

Front

name and version of project and list of dependencies that the project depends on The package.json file holds various metadata about the project. The information is used by npm which allows it to identify the project as well as handle the project's dependencies. When someone installs a Node.js project through npm all the dependencies listed within the package.json file will be installed as well.

Back