OOP = Object Oriented Programming
"사람이 세계를 보고 이해하는 방법을 흉내낸 방법론"
Computer Programming
The 3 Major families of languages are
- Machine Languages
- Assembly Languages
- High-level Languages <- 자바스크립트가 여기 속함
Machine Languages
- comprised of 1s and 0s
- The 'native' languages of a computer
- Difficult to program
- one misplaced 1 or 0 will cause the program to fail
Assembly Languages
- Assembly languages are a step towrards easier programming
- Assembly languages are comprised of a set of elemental commands which are tied to a specific processor
- Assembly language code needs to be translated to machine language before the computer processes it
High-Level Languages
-
The syntax of HL languages is similar to English
-
Interpreter - Executes high level language programs without complilation
-
Historically, we divide HL languages into two groups
- procedural languages
- Object-oriented languages(OOP) (객체지향 언어)
Procedural Languages(절차지향 언어)
- Early high-level languages are typically called procedural languages
- Procedural languages are characterized by sequential sets of linear commands. The focus of such languages is on structure
- Example include C, COBOL, Fortran, LISP, Perl, HTML, VBScript
Object-Oriented Languages(객체지향 언어)
- Programmers code using 'blueprints'of data models called classes
- Examples of OOP languages include
- Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Object Pascal, Objective-C, Dart, Swift, Scala, Common Lisp
-Javascript <<= 초기에는 그다지 아니었으나, 변화를 거치면서 객체지향에 가까워졌음.
What is OOP?
- OOP is mainly a program design philosophy
- OOP use a adifferent set of programming languages than old procedural programming languages (C, Pascal, etc)
- Everything in OOP is grouped as self-sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts.
Classes and Objects
- A class is a prototype, idea and blueprint for creating objects
- An object is an instance of a class
- A class has a constructor for creating objects
- attributes of properties
- method
Encapsulation
- wrapping up of data and function together, into a single unit
- Hide Implementation and Expose behavior
- Loose Coupling: Modify the implementation anytime
아래는 Encapsulation의 예시.
노란박스는 절차지향, 초록박스는 노란박스를 객체지향으로 바꾼 것
Inheritance
Abstraction
Polymorphism
의미: many+form = 여러가지 형태
Without Polymorphism
switch(...) {
case 'select': renderSelect();
case 'text': renderTextBox();
case 'checkbox': renderCheckBox();
case ...
case ...
case ...
}
결론: OOP의 장점
강의: 유튜브 javascript-OOP