1.2.2 Object Oriented Programming
1.2.2 객체지향 프로그래밍
1. 객체지향 프로그래밍 개요
2. 객체지향 프로그래밍의 기본 개념
2.1 클래스(Class)와 객체(Object)
public class Car {
// 속성 (필드)
String color;
String model;
// 생성자
public Car(String color, String model) {
this.color = color;
this.model = model;
}
// 메서드
public void drive() {
System.out.println("The " + color + " " + model + " is driving.");
}
}
// 객체 생성
public class Main {
public static void main(String[] args) {
Car myCar = new Car("red", "Tesla Model S");
myCar.drive();
}
}2.2 추상화(Abstraction)
2.3 캡슐화(Encapsulation)
2.4 상속(Inheritance)
2.5 다형성(Polymorphism)
3. 객체지향 설계 원칙 (SOLID 원칙)
3.1 단일 책임 원칙 (Single Responsibility Principle, SRP)
3.2 개방-폐쇄 원칙 (Open/Closed Principle, OCP)
3.3 리스코프 치환 원칙 (Liskov Substitution Principle, LSP)
3.4 인터페이스 분리 원칙 (Interface Segregation Principle, ISP)
3.5 의존 역전 원칙 (Dependency Inversion Principle, DIP)
4. 객체지향 프로그래밍의 장점과 단점
4.1 장점
4.2 단점
5. 결론
Last updated