Web skill Q&A
What is MVC? Advantages and Disadvantages.
MVC stands for Model, View, Controller. It’s a design pattern which seperates application into three layers of functionality.Model - specifies logical structure of data in an application. It acts as an interface between database and application.
View - specifies all the UI logic, display the output of data.
Controller - act as an interface between Model and View. It processes all the business logic and incoming requests, manipulate data using Model component, and interact with the Views to render the final output.
Pros:
- Decoulping. - change code in one sec without disturbing other unrelated code.
- Support paralled development. - fast
Ability to provide multiple views.
Cons:
Increased complexity.
Rest API
RESTful APIs make use of HTTP protocols as a medium of communication between client and server. We try to have the URLs identify resources, and then use the HTTP actions GET, POST, PUT and DELETE to do stuff to them.Pros:
- Web API may be cleaner and easier to understand / discover.
- Help you organize even a very complex application into simple resources.
JS, JS Library / framework
Javascript is a programming language for the web, it can update and change both HTML and CSS, it can calculate, manipulate and validate data. Javascript Library/Framework are for Javascript-based applications.Library
- jQuery
Greatly simplified Javascript programming.
Features: DOM selection and manipulation. Special effects. Events. Ajax. Cross-browser support.
- jQuery
Framework
- React
For building fast and interactive user interfaces. We see a React Component as a piece of user interfaces. When building application with React, we are actually build a bunch of independent, isolated and reusable components. And with components we can build complex UI. Every React application is actually a tree of components. React reacts to state change. It is View in MVC. Component-based architecture.
Gallery by React. Music Player by React. - Vue
For building fast and interactive user interfaces. Component-based architecture.
Web Reader.
- React
JS Prototype Chain
Inheritance in JavaScript is implemented through the prototype chain. Every normally created object, array, and function has a prototype chain of proto properties ending with Object.prototype at the top. This is why they’re all considered first-class objects in JavaScript.synchronous and asynchronous
synchronous: will be blocked at somewhere waiting a process to be done.
asynchronous: even if there is a procedure need some time to process, the flowing processes will be excecuted .
JavaScript is single threaded and has a synchronous execution model. But in some scenario, it acts like async, for example, timer operates like setInterval and setTimeout, another scenario is web service calls like Ajax calls and the last one is event listener. There is an event loop/queue and when there is some process need to wait, like those three scenario, it will be placed in this queue. When the execution stack is empty, js engine will check this queue and pass the call to corresponding handler and when there is response to these calls.
1 | console.log(100); |