javascript advance Flashcards
Explain modular pattern?
Modular pattern is a design pattern that makes use of javascript object literals notation. it consists of comma seperated key value pairs enclosed in curly brace and can sometimes have function to access them.
How do you add properties to modular pattern
members can be added by assignment using .properties
what are benefits of using modular patterns?
It provides both private and public encapsulation for classes in conventional software engineering.
Module pattern encapsulates “privacy”, state and organisation through using closures.
What is traverson?
Traverson is a hypermedia as the engine of application state (HATEAOS ) client for Node.js
What is Grunt
Grunt is a task runner for javascript which helps in automating common activities like minification, compilation and unit testing. installed from npm using cmd: install grunt –save-dev or install -g grunt-cli
What are some of the main disadvantages of a modular pattern in JavaScript?
Module pattern access to both public and private members are done differently, when we wish to change visibility, we actually have to make changes to each place the member was used.
Private access is hard to update, you can’t access private members in methods that are added to the object at a later point.
Another is the inability to create automated unit tests for private members and additional complexity when bugs require hot fixes. It’s simply not possible to patch privates.
what is the difference between an observer and publish and subscribe pattern.
Observer is a design pattern where an object (known as a subject) maintains a list of objects depending on it (observers), automatically notifying them of any changes to state.
he Observer pattern requires that the observer (or object) wishing to receive topic notifications must subscribe this interest to the object firing the event (the subject).
The Publish/Subscribe pattern however uses a topic/event channel which sits between the objects wishing to receive notifications (subscribers) and the object firing the event (the publisher). This event system allows code to define application specific events which can pass custom arguments containing values needed by the subscriber. The idea here is to avoid dependencies between the subscriber and publisher.
This differs from the Observer pattern as it allows any subscriber implementing an appropriate event handler to register for and receive topic notifications broadcast by the publisher.
What is morgan
Morgan is a logger, it can be used to identify clients accessing the application.
What is Redux?
Redux is a state management library. It uses a store which where the state is monitored. It makes use of an immutable object called actions to record state changes
and a reducer which is a pure function used to make changes to state. This is done by dispatching the action which triggers the reducers.
How is Redux used in react
To implement Redux on a react application you need the react-redux library, you can then use a Provider which is a component that provides the store for the states, It acts as a wrapper for the app and allows you to create a Store (createStore).You then need to connect to the components using the { connect } and then map using mapStateToProps and mapDispatchToProps to map to store state and dispatch to props of component