Introduction to JavaScript. OOP in JavaScript

Слайд 2

OOP, What is it? Something about objects and classes Encapsulation Polymorphism Abstraction Inheritance

OOP, What is it?

Something about objects and classes

Encapsulation

Polymorphism

Abstraction

Inheritance

Слайд 3

Why do we need it? Computer doesn’t care how elegant your

Why do we need it?

Computer doesn’t care how elegant your code

is, people do.

Creating of models works better if you have right amount of right abstractions.

Any statement which may have only one meaning within its context can be used as a piece of program code.

Слайд 4

More about programming paradigms Imperative Functional Logic programming Declarative

More about programming paradigms

Imperative

Functional

Logic programming

Declarative

Слайд 5

Web application in general Runs in browser Requires client-server communication Interactivity No complex computing

Web application in general

Runs in browser

Requires client-server communication

Interactivity

No complex computing

Слайд 6

Let’s talk about JavaScript No Classes Everything but primitives is an object

Let’s talk about JavaScript

No Classes

Everything but primitives is an object

Слайд 7

JS Data Types

JS Data Types

Слайд 8

Aliases

Aliases

Слайд 9

First-class function

First-class function

Слайд 10

How to get a class

How to get a class

Слайд 11

What about other OOP concepts? Encapsulation

What about other OOP concepts?

Encapsulation

Слайд 12

Scope

Scope

Слайд 13

More about closure (A Counter Dilemma)

More about closure
(A Counter Dilemma)

Слайд 14

Inheritance prototype Anything wrong with this? “Mammal” is not a “class”

Inheritance

prototype

Anything wrong with this?

“Mammal” is not a “class”

Слайд 15

Use prototype properly

Use prototype properly

Слайд 16

What is “this”?

What is “this”?

Слайд 17

"apply" and "call" methods

"apply" and "call" methods

Слайд 18

Software design pattern They're not supposed to make your life more difficult They're not a panacea

Software design pattern

They're not supposed to make your life more difficult


They're not a panacea

Слайд 19

Types of patterns

Types of patterns

Слайд 20

Singleton

Singleton

Слайд 21

Module

Module

Слайд 22

Mediator

Mediator

Слайд 23

Conclusions Everything including functions is variable Everything but primitives is object

Conclusions

Everything including functions is variable

Everything but primitives is object

Primitive variables are

variables object variables are aliases

Function called with new turns out to class constructor

prototype can be used for defining class methods and properties

Use closure for encapsulation

Don’t forget about context

Слайд 24

Home work

Home work