'5. Documentation/Coding Convention'에 해당되는 글 4건
- 2011.08.17 [Java] CheckStyle and eclipse-cs
- 2011.07.18 Microsoft StyleCop
- 2010.12.08 Code Conventions for the JavaServer PagesTM Version 1.x Language
- 2008.06.15 Doxygen 주석 활용 [VC++ 스타일]
[Java] CheckStyle and eclipse-cs

http://eclipse-cs.sourceforge.net/
http://checkstyle.sourceforge.net/
를 참고하시면 되며,
http://eclipse-cs.sourceforge.net/downloads.html
에 설치 방법 또한 자세하게 나옵니다.
설치 후에, 아래 페이지를 참고하여 프로젝트에 CheckStyle 을 적용해 봅시다.
http://eclipse-cs.sourceforge.net/basic_setup_project.html
여러 명이서 코드 작업할 때, 일관성을 유지하면서 가독성을 높이기 위해서는 옵션이 아닌 필수적인 선택입니다.
저의 경우는 Visual Studio 2008 에 적용하여 사용하고 있는데, 무척이나 만족스럽습니다.
몇가지 맘에 들지 않거나 너무 불편한 것들이 있으면 이를 예외로 설정할 수도 있습니다. 또, Custom Rule 도 정의할 수 있는 것 같습니다 (코딩을 해야 하는 것 같아 깊게 살펴보지는 않았습니다).
적용한 방식은 다음과 같습니다.
하나의 솔루션에 여러개 (약 8~9개)의 C# 프로젝트가 있었습니다. 모든 프로젝트에 적용하면 고치는 양이 너무 많을 것 같아 프로젝트 하나씩 적용하였습니다. 또한 외부에서 가져온 소스 역시 스타일에 예외토록 하였습니다. 그리고 Global 하게 적용될 수 있는 설정을 만들고 이를 각 프로젝트에 merge 하여 동시에 적용되도록 하였습니다.
이렇게 하기 위해 솔루션 밑에 StyleCop 설정 파일을 두고, 이를 각 프로젝트 밑의 StyleCop 설정파일과 merge 되도록 하였습니다. 그리고 빌드 시 Style 이 일치하지 않으면 경고가 아닌 에러를 일으키도록 하여 무조건 수정을 하도록 강제하였습니다.
StyleCop 과 관련된 설치법과 설치에 대한 자세한 내용은 아래 링크를 참고하시기 바랍니다.
StyleCop 공식 페이지
http://stylecop.codeplex.com/
글로벌 세팅 파일 만들기
http://code-inside.de/blog-in/2010/12/19/howto-apply-stylecop-settings-on-several-projects/
파일 예외처리하기
http://blogs.msdn.com/b/sourceanalysis/archive/2008/11/11/introducing-stylecop-on-legacy-projects.aspx
Code Conventions for the JavaServer PagesTM Version 1.x Language

Doxygen 주석 활용 [VC++ 스타일]

//////////////////////////////////////////////////////////////////////////
/// @brief Test Class for an example of doxygen usage
/// @remark More Information
/// @author Jihoon.Yim
/// @version V1.0
/// @date 3/21/2008
//////////////////////////////////////////////////////////////////////////
/// @note I changed my mind.
/// @todo I will have to think more complex design on this class.
class Test
{
int Add(int i, int j);
int Sum(int i, int j);
};
//////////////////////////////////////////////////////////////////////////
/// @brief Add two parameters and then return the sum
/// @param i Integer value
/// @param j Integer value
/// @exception Throws an exception when error occurs.
/// @return Return (i+j)
/// @retval -1 Failed to add
/// @remark More Information
/// - Item 1
/// -# Sub Item 1
/// -# Sub Item 2
/// .
/// - Item 2
/// .
/// @code
/// int i=3;
/// int j=3;
/// try
/// {
/// int result = Add(i, j);
/// }
/// catch
/// {
/// ...
/// }
/// @endcode
/// @author Jihoon.Yim (A company)
/// @author Gildong.Hong (B consulting company)
/// @date 3/21/2008
//////////////////////////////////////////////////////////////////////////
/// @bug [Fixed 3/22/2008 Jihoon.Yim] That was not correct in some cases.
/// @bug [Fixed 3/21/2008 Jihoon.Yim] I forgot some calculation. (Fixed 3/23/2008)
/// @warning Watch out when using this class.
int Test::Add(int i, int j)
{
return (i+j);
}
//////////////////////////////////////////////////////////////////////////
/// @brief Add two parameters and then return the sum
/// @param i Integer value
/// @param j Integer value
/// @return Return (i+j)
/// @retval -1 Failed to add
/// @author Jihoon.Yim
/// @date 3/21/2008
//////////////////////////////////////////////////////////////////////////
int Test::Sum(int i, int j)
{
return (i+j);
}