HomeBlogGuestbookLab 

JDM's Blog

온갖 테스트 결과가 기록되는 이곳은 JDM's Blog입니다. :3

Convention over configuration(CoC)의 이해

최근에 기술적인 공부를 하다보면 CoC(Convention over configuration)에 대해 자주 언급하는 문장들이 있습니다. CoC가 대체 뭔지 한번 제대로 각잡고 공부하기 위한 포스팅입니다.

CoC의 정의

우선 CoC가 무엇인지 위키피디아에서 검색을 해봤더니 있네요.

Convention over configuration (also known as coding by convention) is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.

Wikipedia - Convention over configuration

CoC(Convention over configuration)는 개발자들에게 결정할 개수를 줄여서 개발을 용이하고 단순하게 하지만 그렇다고 해서 유연성을 잃지 않게 하도록 하는 소프트웨어 디자인 패러다임이라고 합니다.

이것만으로는 사실 와닿는게 없네요. 조금 더 인용을 통해서 알아봅시다.

그러니까 어떤거에요?

The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there is a class Sale in the model, the corresponding table in the database is called "sale" by default. It is only if one deviates from this convention, such as calling the table "sales", that one needs to write code regarding these names.

When the convention implemented by the tool matches the desired behavior, it behaves as expected without having to write configuration files. Only when the desired behavior deviates from the implemented convention is explicit configuration required.

Wikipedia - Convention over configuration

CoC가 뜻하는 것은 개발자는 애플리케이션에 자유로운 측면에 대해서만 지정이 필요하다는 겁니다. 예를 들자면 모델 안에 Sale 이라는 클래스가 있다고 가정합시다. 그리고 해당 테이블은 데이터베이스 내에서 기본적으로 sale 이라고 하는 겁니다. 테이블 이름을 sales 같은 별도 지정으로 인해 하나가 관례를 벗어난다면 이 벗어난 것에 대해서만 코드가 필요하고 작성하면 됩니다.

도구에 포함된 관례가 요구된 동작과 일치할 때 이것은 구성 파일을 작성하지 않아도 예상된 동작을 합니다. 단지 요구된 동작이 도구에 포함된 관례를 벗어날 때 명시적인 설정이 요구 됩니다.

…정말 영어는 쥐약입니다. 아무튼 이제는 조금 알겠네요. CoC가 적용되어 있는 도구라면 도구 내에 자체적으로 지원하는 관례에 벗어나는 것에만 설정을 해주면 된다는 것이군요. 그 외에는 도구에 포함된 관례에 맞춰서 개발한다면 설정이 필요 없다는 얘기와도 같습니다.

수많은 설정 파일로 인해서 오류가 날 수도 있고 또한 신경 쓰는것도 어려워지지만, 관례를 통해서 많은 설정을 삭제하거나 줄일수만 있어도 개발자의 생산성은 많이 올라갈 것으로 예상이 됩니다. :)

Closing Remarks

앞으로 CoC라는 단어가 나오면 당황해 하지 않아야겠네요. :3