📅날짜

2025/08/06

💡페어 프로그래밍

이번 백엔드 수업 시간에 협업 능력과 문제 해결 능력을 키우기 위해 페어 프로그래밍 실습을 진행했다.

페어 프로그래밍이란?

페어 프로그래밍은 두 명의 프로그래머가 하나의 컴퓨터에서 함께 작업하는 애자일 소프트웨어 개발 방식이다. 한 명은 코드를 작성하는 Driver, 다른 한 명은 코드 검토와 방향 제시를 하는 Navigator 역할을 번갈아 맡는다. 이를 통해 실시간 피드백과 지식 공유가 가능해 코드 품질과 개발 효율성을 높일 수 있다.

📖진행 과정

프로그래머스 - 완주하지 못한 선수

이번 실습에서는 프로그래머스의 ‘완주하지 못한 선수’ 문제를 해결했다. 각자 10분씩 문제를 해석한 후, 10분 간격으로 Driver와 Navigator 역할을 바꿔가며 코딩했다.
Driver는 직접 코드를 작성하고, Navigator는 로직 검토와 아이디어를 제시했다. 언어는 Python과 Java 두 번에 걸쳐 진행했다.

파이썬

def solution(participant, completion):
    answer = ''
    from collections import defaultdict
    parti_dict = defaultdict(int)
    for person in participant:
        parti_dict[person] += 1
    for completeperson in completion:
        parti_dict[completeperson] -= 1
        if parti_dict[completeperson]==0:
            del parti_dict[completeperson]
    answer = list(parti_dict.keys())[0]
    return answer

자바

import java.util.HashMap;
import java.util.Map.Entry;
class Solution {
    public String solution(String[] participant, String[] completion) {
         String answer = "";
        HashMap<String,Integer> hashmap = new HashMap<String,Integer>();
        for(int i=0;i<participant.length;i++) {
            if(hashmap.containsKey(participant[i]))
                hashmap.put(participant[i], hashmap.get(participant[i])+1);
            else
                hashmap.put(participant[i], 1);
        }
        for(int i=0;i<completion.length;i++) {
            if(hashmap.get(completion[i])==1)
                hashmap.remove(completion[i]);
            else
                hashmap.put(completion[i], hashmap.get(completion[i])-1);
        }
        for (Entry<String, Integer> entrySet : hashmap.entrySet()) {
            answer+=entrySet.getKey();
            //System.out.println(entrySet.getKey() + " : " + entrySet.getValue());
        }
        //System.out.println(answer);
        return answer;
    }
}

🎓후기

첫 경험이라 변수명 규칙(카멜 표기 vs 스네이크 표기)에서 의견이 달랐다. 결국 Driver의 재량에 맡겼지만, 이 과정에서 코딩 컨벤션의 중요성을 느꼈다. 또한 Driver가 혼자 주도해서 작성하는 ‘자율주행’ 상황이 생기기도 했다. 다음에는 사전 합의와 짧은 주기의 역할 교대를 통해 더 원활하게 진행해 보고 싶다.

🏆느낀점

페어 프로그래밍은 단순히 같이 코딩하는 것을 넘어, 서로의 사고방식을 이해하고 존중하는 과정이라는 걸 느꼈다. 다음에는 팀원과 컨벤션부터 맞추고 시작해야겠다.

profile
takeitEasy

0개의 댓글