정의 알고리즘의 골격(순서) 는 부모 클래스가 고정하고, 그 안의 일부 단계만 자식클래스가 채우게 하는 패턴이다. "언제 무엇을 호출할지"는 부모가 쥐고, 자식클래스는 "그 단게에서 무엇을 할지"만 정한다. ex) public abstract class SeasonedEventPart { // 템플릿 메서드: 골격. 자식클래스가 순서를 바꿀 수 없다 public bool IsSeasonOpen(DateTime nowUtc) { var config = GetSeasonConfig(); if (config == null) return false; if (IsRolledOver(config, nowUtc)) return false; return nowUtc >= config.StartUtc && nowUtc < config.EndUtc; } // 필수 단계: 자식클래스가 반드시 채운다 protected abstract EventSeasonConfig GetSeasonConfig(); // 훅: 기본 구현이 있고, 필요할 때만 덮어쓴다 protected virtual bool IsRolledOver(EventSeasonConfig config, DateTime nowUtc) => false; } 구성 요소 * 탬플릿 메서드 * 부모 클래스에 있고, 자식 클래스가 덮어쓰지 못한다 (C#에서는 virtual을 안 붙이면 됨) 자시 클래스의 다른 메서드들을 정해진 순서로 호출한다. 즉, 직접 일을 다 하지 않고 순서만 쥔다. 그 호출되는 메서드 중 최소 하나가 abstract 또는 virtual 이다. 서브클래스가 채우는 자리가 있어야 한다. Strategy와 차이 C# 은 단일 상속이라, 이미 다른 베이스를 상속 중인 클래스에서는 Template Method를 쓸 수 없다.
New research from GitHub and Yale Program on Climate Change Communication finds strong demand for tools, measurement, and practical guidance that can help developers reduce wasted compute. The post Developers want more efficient software. Here’s what over 1,000 GitHub users told us they need. appeared first on The GitHub Blog .