본문 바로가기

프로그래밍

YAGNI

반응형

YAGNI 은(는) You Aren't Gonna Need It 의 축약어로,

당장 필요하지 않으면 추후 확장성을 고려한 설계를 하지 않을 것을 의미하는 개발의 기본 원칙이에요.

Bad

final class Program
{
	public static void main(String[] args)
	{
		System.out.println(add(10, 20));
	}

	public static int add(int a, int b)
	{
		return a + b;
	}

	public static int subtract(int a, int b) // you aren't gonna need it
	{
		return a - b;
	}

	public static int multiply(int a, int b) // you aren't gonna need it
	{
		return a * b;
	}
}

Good

final class Program
{
	public static void main(String[] args)
	{
		System.out.println(add(10, 20));
	}

	public static int add(int a, int b)
	{
		return a + b;
	}
}
반응형

'프로그래밍' 카테고리의 다른 글

Naming Convension  (0) 2024.04.14
Code Style  (0) 2024.04.13
SOLID  (0) 2024.04.12
KISS  (0) 2024.04.10
DRY  (3) 2024.04.09