TIL - 블로그(기사)
[글] 마틴 파울러가 알려주는 ChatGPT와 페어 프로그래밍 하는 법
cocokaribou
2023. 7. 6. 10:57
요즘 ChatGPT를 정말 많이 사용하는데,
코드 짜다가 단편적인 부분에 대해서만 물어보는 바람에
소스코드 안에서 코드의 패러다임이 안 맞을 때가 있다.
<리팩토링> 저자가 말하는 ChatGPT랑 협업하기 팁을 참고하면
프로젝트 설계부터 구현까지 ChatGPT를 유용하게 사용할 수 있겠다.
유용해보이는 영어 표현들도 같이 기록.
원문 기사 : An Example of LLM Prompting for programming
* LLM(Large Language Model) Prompting : 코드가 아닌 자연어로 AI와 상호작용하게 해주는 프롬트.
마틴 파울러가 알려주는 ChatGPT와 페어 프로그래밍 하는 법
[한국어 번역] An example of LLM prompting for programming by Martin Fowler
sigridjin.medium.com
1. 풀고자 하는 문제의 맥락을 설명
- 어떻게 설계되면 좋겠는지
- Here are the common implementation strategy:
- 이 아래로 번호로 매겨도 ok.
- 기술스택 목록
- All codes should be written in the tech stack mentioned above.
- 테스트 방법
- Here are certain patterns should be followed when implement and test the component
- 예시)
1. When write test, use describe instead of test
2. Data-driven tests are preferred.
3. When test the view component, fake view model via the view model interface
- "코드는 작성하지 말아라"
- Don’t generate code(yet). Describe the solution, and breaking the solution down as a task list based on the guidance mentioned above. And we will refer this task list as our master plan.
- 코드를 바로 적게 하지 않고 Task List 작성을 유도한다.
- Generated Knowledge
- 비밀로 유지되어야 하는 실제 프로덕션 코드를 절대 넣어서는 안 된다
- 당연한 사실이지만 다시 리마인드
2. 꼬리를 무는 질문하기
- Task List에서 수정사항 있으면 번호를 지시해서 재작성 명령하기
- 피드백 주고받으면서 아키텍처 수정해나가기
3. 컴포넌트 이름 짓게 하기
- Task List 작성이 완료되면 디테일을 요구한다
- Rewrite the master plan, this time with detailed component names, methods, and prop
4. 코드 작성시키기
- 코드 컨벤션에 맞춰서 리팩토링을 지시할 수 있다.
- Token Limit 극복하기
- 답변이 중간에 멈췄을 때 "You are not finished." 혹은 "Go on."
- 대화가 길어질수록 앞서 언급된 컨텍스트를 까먹는다.
- 그래서 Task List의 번호 매기는 것이 도움된다.
정리
프로젝트 요구사항을 Task List로 구조화한 뒤,
리스트 항목의 내용을 구체화시켜나가는 방향으로 대화를 유도한다.
728x90