0Pricing
Clean Architecture & Design Patterns in Practice · 강의

SOLID 원칙 개요

단일 책임, 개방-폐쇄, 리스코프 치환, 인터페이스 분리, 의존성 역전이라는 다섯 가지 SOLID 원칙을 소개합니다.

SOLID 원칙 개요은(는) CoddyKit의 무료 Clean Architecture & Design Patterns in Practice 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Clean Architecture & Design Patterns in Practice 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Clean Architecture & Design Patterns in Practice 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What are SOLID Principles?

The SOLID principles are five design guidelines for software that’s easy to maintain, understand, and extend. Think of them as a path to cleaner code.

Why SOLID Matters

Applying SOLID gives you code that’s easier to understand, simpler to test, more flexible to change, and friendlier to teamwork. It’s the bedrock of good OO design.

S: Single Responsibility Principle (SRP)

The Single Responsibility Principle: a class should have one reason to change. Don’t mix calculating data and saving it — split those concerns apart.

SRP in Action: Simple Report

This SimpleReport obeys SRP: its only job is generating report content. Printing and saving are someone else’s responsibility.

public class SimpleReport {
  private String content;

  public SimpleReport(String content) {
    this.content = content;
  }

  // This class's single responsibility is to generate/represent the report content
  public String generateReportContent() {
    return "Report: " + content;
  }

  public static void main(String[] args) {
    SimpleReport report = new SimpleReport("Sales Data for Q1");
    System.out.println(report.generateReportContent());
  }
}

O: Open/Closed Principle (OCP)

The Open/Closed Principle: software should be open for extension but closed for modification. Add new behavior without editing working code.

OCP in Action: Flexible Greeters

Here a new greeter type slots in without touching the Greeter interface or existing classes — extending behavior, not modifying it. That’s OCP.

interface Greeter {
  String greet();
}

class EnglishGreeter implements Greeter {
  @Override
  public String greet() {
    return "Hello!";
  }
}

class SpanishGreeter implements Greeter {
  @Override
  public String greet() {
    return "¡Hola!";
  }
}

public class OCPDemo {
  public static void main(String[] args) {
    Greeter english = new EnglishGreeter();
    Greeter spanish = new SpanishGreeter();
    System.out.println(english.greet());
    System.out.println(spanish.greet());
  }
}

L: Liskov Substitution Principle (LSP)

The Liskov Substitution Principle: a subclass must be usable anywhere its parent is expected, without breaking the program. Subtypes honor the contract.

LSP in Action: Shapes

Any function taking a Shape handles both Rectangle and Circle correctly — they honor the contract. That’s LSP at work.

interface Shape {
  double getArea();
}

class Rectangle implements Shape {
  private double width; 
  private double height;

  public Rectangle(double width, double height) {
    this.width = width;
    this.height = height;
  }

  @Override
  public double getArea() {
    return width * height;
  }
}

class Circle implements Shape {
  private double radius;

  public Circle(double radius) {
    this.radius = radius;
  }

  @Override
  public double getArea() {
    return Math.PI * radius * radius;
  }
}

public class LSPDemo {
  public static void printArea(Shape shape) {
    System.out.println("Area: " + shape.getArea());
  }

  public static void main(String[] args) {
    Shape myRectangle = new Rectangle(5, 4);
    Shape myCircle = new Circle(3);

    printArea(myRectangle);
    printArea(myCircle);
  }
}

I: Interface Segregation Principle (ISP)

The Interface Segregation Principle: don’t force clients to depend on methods they don’t use. Prefer many small, focused interfaces over one fat one.

D: Dependency Inversion Principle (DIP)

The Dependency Inversion Principle: high-level and low-level modules should both depend on abstractions, not concrete details. That’s how you get loose coupling.

Check Your Understanding

Which of the following statements correctly describe the benefits of applying SOLID principles?

Recap: The Power of SOLID

You’ve met all five SOLID principles — single responsibility, open/closed, Liskov, interface segregation, dependency inversion — the toolkit for adaptable software.

자주 묻는 질문

“SOLID 원칙 개요” 강의는 무료인가요?

네 — “SOLID 원칙 개요” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Clean Architecture & Design Patterns in Practice 강의 전체를 잠금 해제할 수 있습니다. Clean Architecture & Design Patterns in Practice 강의에는 총 4개의 강의가 포함되어 있습니다.

“SOLID 원칙 개요”에서 뭘 배우나요?

단일 책임, 개방-폐쇄, 리스코프 치환, 인터페이스 분리, 의존성 역전이라는 다섯 가지 SOLID 원칙을 소개합니다. 브라우저에서 직접 실행하는 실습 코드로 Clean Architecture & Design Patterns in Practice을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Clean Architecture & Design Patterns in Practice을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Clean Architecture & Design Patterns in Practice은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“SOLID 원칙 개요” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Clean Architecture & Design Patterns in Practice 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Clean Architecture & Design Patterns in Practice 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 클린 코드 소개
  2. SOLID 원칙 개요
  3. 좋은 설계의 가치
  4. 응집도, 결합도, 관심사 분리
← Clean Architecture & Design Patterns in Practice(으)로 돌아가기