Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 2.8 KB

File metadata and controls

57 lines (42 loc) · 2.8 KB

Authentication

Review, Research, and Discussion

Explain what a “Singleton” is (in Computer Science terms)

  • A singleton is a class that allows only a single instance of itself to be created and gives access to that created instance. source

Explain how the Singleton pattern can be used with Node modules, specifically with classes

  • singleton classes can be made in their own node.js modules and exported and cached for use throughout the rest of the code.
    • create a Singleton class
    • call new Singleton() as it is exported
    • node will cache it for use elseware
    • source

If you were tasked with building a middleware system like Express uses, what approach might you take to construct/operate it?

  • I would build these functions with a class. On the class I would have the specific methods for use, get, post, put, delete that would all take a in a http route and a callback.

Vocab

Router Middleware

  • Middleware that handles all of the data handleing between recieving a request from an http method, to sending back the response. Dynamic Module Loading
  • Allows you to only load the modules that your code needs to execute a request. The reason you would want to do this is to improve intial page load speed, prevent browser from downloading unecessary code, and for global uses cases only downloading the locale required.

Singleton Pattern

  • A singleton is a class that allows only a single instance of itself to be created and gives access to that created instance. source

CRUD -> REST Method Matches -CREATE -> POST -READ -> GET -UPDATE -> PUT, PATCH -DELETE -> DELETE

Mock Testing

  • an approach that makes assumption about how the code you are testing interacts with other code. By using mock testing dependencies are replaced with objects that simulate the response. The purpose is to focus on the code being tested and not the external dependencies. source

Preview

Which 3 things had you heard about previously and now have better clarity on?

  1. Singleton Pattern
  2. Mock Testing
  3. Router Middleware

Which 3 things are you hoping to learn more about in the upcoming lecture/demo?

  1. Singleton Pattern
  2. Mock Testing
  3. Dynamic Module Loading

What are you most excited about trying to implement or see how it works?

  • Singleton Pattern

Resources