interpreter - compile하지 않고 한줄씩 바로바로 변환
절차 지향
C, HTML
절차를 중시
객체 지향(Object Oriented Programming)
Java, C++, C#, Python, JavaScript, Ruby
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
OOP의 특징이자 장점
Encapsulation Reduce complexity + increase reusability
Abstraction Reduce complexity + isolate impact of changes
Inheritance Eliminate redundant code
Polymorphism Refactor ugly switch/case statements
Encapsulation
e.g.
let baseSalary = 30_000;
let overtime = 10;
let rate = 20;
function getWage(baseSalary, overtime, rate) {
return baseSalary + (overTime * rate);
let employee = {
baseSalary: 30_000,
overtime: 10,
rate: 20,
getWage: function() {
return this.baseSalary + (this.overtime * this.rate);
}
};
employee.getWage();
위에가 절차 지향적
아래가 객체 지향적
위를 아래로 바꿔주는 것이 Encapsulation
Inheritance
상위 객체의 특징을 베이스로 하여 새로운 기능을 추가적으로 넣는 것
Abstraction 추상화
내부 구조는 복잡하더라도 사용하는데 알아야할 정보는 간단하다
Polymorphism
참고 자료
Introduction to object oriented programming, Moutaz Haddara,
https://www.slideshare.net/haddara1/introduction-to-object-oriented-programming-42639494
Programming with Mosh,
https://www.youtube.com/watch?v=PFmuCDHHpwk