BACKEND·중요도 6·2026. 05. 27.·Dev.to

Is it a good practice to use a single Builder pattern for both Creating and Updating an entity?

── KO ──────────────────

Builder 패턴을 하나로 사용하여 엔티티를 생성 및 업데이트하는 것이 좋을까요?

노드.js(타입스크립트) 백엔드에서 Permission 객체를 만들기 위해 Builder 패턴을 구현하고 있습니다. 생성 시 id가 필요 없고 name, module이 필수이며, 업데이트 시 id가 필수이고 name과 module은 하나만 제공되어야 하는 조건이 있습니다. 이와 같은 조건부 논리를 하나의 Builder에서 처리하는 것이 좋은지, 아니면 별도의 빌더로 나누는 것이 더 나은지 질문하고 있습니다.


── EN ──────────────────

Is it good practice to use a single Builder for both creating and updating an entity?

In a Node.js (TypeScript) backend, the author is implementing the Builder pattern to instantiate a Permission object. The requirements differ significantly between creating (id not needed, name and module are mandatory) and updating (id is mandatory, but name and module are optional with specific rules). The author questions whether to handle this conditional logic in one Builder or to split it into separate builders for create and update operations.

원문 보기 →목록으로