Angular concepts underlines
Syntax: module.service( ‘serviceName’, function );
Result: When declaring serviceName as an injectable argument you will be provided the actual function reference passed to module.service.
Usage: Could be useful for sharing utility functions that are useful to invoke by simply appending () to the injected function reference. Could also be run with injectedArg.call( this ) or similar.
Syntax: module.factory( ‘factoryName’, function );
Result: When declaring factoryName as an injectable argument you will be provided the value that is returned by invoking the function reference passed to module.factory.
Usage: Could be useful for returning a ‘class’ function that can then be new’ed to create instances.
Syntax: module.provider( ‘providerName’, function );
Result: When declaring providerName as an injectable argument you will be provided the value that is returned by invoking the $get method of the function reference passed to module.provider.
Usage: Could be useful for returning a ‘class’ function that can then be new’ed to create instances but that requires some sort of configuration before being injected. Perhaps useful for classes that are reusable across projects? Still kind of hazy on this one.
Angular e React tools
HTTP/2 allows a server to pre-emptively send (or “push”) responses (along with corresponding “promised” requests) to a client in association with a previous client-initiated request. This can be useful when the server knows the client will need to have those responses available in order to fully process the response to the original request.
- <EvalError> : thrown when a call to
- <RangeError> : thrown when a value is not within an expected range
- <ReferenceError> : thrown when using undefined variables
- <TypeError> : thrown when passing arguments of the wrong type
- <URIError> : thrown when a global URI handling function is misused.
Are all programming languages imperatives?
In computer science, imperative programming is a programming paradigm that uses statements that change a program’s state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates.
Procedural programming is a type of imperative programming in which the program is built from one or more procedures (also termed subroutines or functions). The terms are often used as synonyms, but the use of procedures has a dramatic effect on how imperative programs appear and how they are constructed. Heavily-procedural programming, in which state changes are localized to procedures or restricted to explicit arguments and returns from procedures, is termed structured programming. From the 1960s onwards, structured programming and modular programming in general have been promoted as techniques to improve the maintainability and overall quality of imperative programs. Object-oriented programming extends this approach.
Procedural programming could be considered a step towards declarative programming. A programmer can often tell, simply by looking at the names, arguments, and return types of procedures (and related comments), what a particular procedure is supposed to do, without necessarily looking at the details of how it achieves its result. At the same time, a complete program is still imperative since it fixes the statements to be executed and their order of execution to a large extent.
Contrasting with imperative and procedural programming is declarative programming, a non-imperative programming style in which programs describe their desired results without explicitly listing commands or steps that must be performed.
The hardware implementation of almost all computers is imperative.[note 1] Nearly all computer hardware is designed to execute machine code, which is native to the computer, written in the imperative style.
From this low-level perspective, the program state is defined by the contents of memory, and the statements are instructions in the native machine language of the computer. Higher-level imperative languages use variables and more complex statements, but still follow the same paradigm.
The earliest imperative languages were the machine languages of the original computers. In these languages, instructions were very simple, which made hardware implementation easier, but hindered the creation of complex programs. FORTRAN, developed by John Backus at International Business Machines (IBM) starting in 1954, was the first major programming language to remove the obstacles presented by machine code in the creation of complex programs. FORTRAN was a compiled language that allowed named variables, complex expressions, subprograms, and many other features now common in imperative languages.
From this Source.
.factory no AngularJS são métodos no nosso módulo principal (app), que recebem um nome e uma função que o definem.
Uma vez definido, podemos injetar e usar
.factory em outros componentes. Basta colocá-los como dependência em Directives, Controllers e Filters.
AngularJS funções contrutoras e ‘class-like’
.service é uma função construtora, enquanto um
.factory é somente uma função que é chamada. Por este motivo precisamos retornar um objeto.
Como regra geral, nós usamos
.factory para funções “class-like”, nas quais você pode adicionar propriedades/atributos e retornar para um controller.
Por outro lado, podemos usar
.service para compartilhar funções utilitárias/construtoras.
- Função Construtora, Utilitária
- Retorna uma instância dele mesmo
- Usa this ou vm = this
- new ServiceName()
- Função Class-like
- Retorna um novo Objeto
- Pode adicionar propriedades e atributos
Object Oriented programming language
Abstract Classes => Models, Controllers
Methods => Functions
Constructors Methods => Services
Views => DOM
|Template||HTML with additional markup|
|Directives||extend HTML with custom attributes and elements|
|Model||the data shown to the user in the view and with which the user interacts|
|Scope||context where the model is stored so that controllers, directives and expressions can access it|
|Expressions||access variables and functions from the scope|
|Compiler||parses the template and instantiates directives and expressions|
|Filter||formats the value of an expression for display to the user|
|View||what the user sees (the DOM)|
|Data Binding||sync data between the model and the view|
|Controller||the business logic behind views|
|Dependency Injection||Creates and wires objects and functions|
|Injector||dependency injection container|
|Module||a container for the different parts of an app including controllers, services, filters, directives which configures the Injector|
|Service||reusable business logic independent of views|