View on GitHub

reading-notes-401

Classes, Inheritance, Functional

By Abdallah obaid

NAME URL
Home Home.
Prep Prep: Engineering Topics.
Read 01 Node Ecosystem, TDD, CI/CD.
Read 02 Classes, Inheritance, Functional.
Read 03 Data Modeling & NoSQL Databases.
Read 04 Advanced Mongo/Mongoose.
Read 05 Linked Lists.
Read 06 HTTP and REST.
Read 07 Express.
Read 08 Express Routing & Connected API.
Read 09 API Server.
Read 10 Stacks and Queues.
Read 11 Authentication.
Read 12 OAuth.
Read 13 Bearer Authorization.
Read 14 Access Control (ACL).
Read 15 Trees.
Read 16 Event Driven Applications.

Classes, Inheritance, Functional:-


## Functional programming: *(often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects.

## pure function : 1- Always returns the same result if the same arguments are passed in. It does not depend on any state, or data, change during a program’s execution. It must only depend on its input arguments. 2- Does not produce any observable side effects such as network requests, input and output devices, or data mutation.

## Higher-order functions::

## Immutable state :

## JavaScript object:

## Object-oriented programming:

## class:

## prototype:

## Super:

## Inheritance:

## Constructor:

## Context :

## this :

## TDD :

## Jest :

## Continuous Integration (CI) :

## Unit testing :


Reading, Research, and Discussion:-


  1. Name 3 advantages to Test Driven Development:
    • Writing the tests first requires you to really consider what do you want from the code.
    • You receive fast feedback.
    • TDD creates a detailed specification.
    • TDD reduces time spent on rework.
  1. In what case would you need to use beforeEach() or afterEach() in a test suite?
    • If you have some work you need to do repeatedly for many tests, you can use beforeEach and afterEach.
  1. What is one downside of Test Driven Development:
    • Is that if you really want to do TDD properly you will have to fail a lot before you succeed. Given how many software companies work (dollar per KLOC) you will eventually get fired.
  1. What’s the primary difference between ES6 Classes and Constructor/Prototype Classes?
    • ES6 class basically does the work of defining a new object and appending functions to its prototype, ES5 Function constructors work and look the same but the main difference is observed when the developer uses the Inheritance property.
  1. Name a use case for a static method: class User { static staticMethod() { alert(this === User); } } User.staticMethod(); // true
  1. Write an example of a Higher Order function and describe the use case it solves:
    • The snippet below loops over an array and invokes a function on each item until it has reached the last item. The capability of taking a function that it can invoke is what makes it a higher order function: function prefixWordWithUnderscore(word) { return _${word} } const words = [‘coffee’, ‘apple’, ‘orange’, ‘phone’, ‘starbucks’] const prefixedWords = words.map(prefixWordWithUnderscore) // result: [“_coffee”, “_apple”, “_orange”, “_phone”, “_starbucks”]

npm