Pair programming is the practice of programming where two programmers work side by side on one computer and sharing one screen, keyboard and mouse collaborating on the same algorithm, design, coding and testing it.
Pair programming is generally a growing software development technique where two individuals work on a single block of code. The programmers undertake one out of two parts — the Driver and the navigator.
The one who has control over the keyboard or mouse who writes the code and tests it, is known as a driver and the other one observes the work of the driver and then identifies the defects made and strategically thinks about the direction of work. This is the other type of programmer known as the navigator.
Here, the two programmers switch their roles accordingly contribute and share their work equally to develop a software.
Why do we need pair programming?
Both the programmers must verbalize their thought processes for paired programming to become effective. Pair programming relies on successful communication as much as programming skill. The premise is that when working on a complex task, “two heads are better than one.” This is why pair programming is preferred.
IMPORTANCE OF PAIR PROGRAMMING:
1.Mutual learning and development of skills.
2.Better solutions are produced.
3.Teamwork within the organisation.
4.Sharing knowledge and context.
5. Improve the productivity and quality of software products.
PRINCIPLES OF PAIR PROGRAMMING:
2. Strong-Style Pairing
3. Ping-Pong Pairing
4. Unstructured Pairing
In this approach, two programmers work on the same code, one person will type the code and the other will navigate. The driver carries out the navigator’s instructions, but has the opportunity to make corrections or ask for clarification. One person will be watching the code being typed and the other codes. The driver and navigator will be switching roles regularly every 15 minutes or so.
In Strong-style pairing, the driver does nothing that the reviewer did not direct them to do. Whenever the driver requires pitching in the idea, he/she must handover the system to his/her partner and then carryout the control from the observer position. This approach completely engages the observer.
In this pair programming, the conjunction with Test-Driven Development is performed. One programmer will be writing a test and the other programmer makes the test pass. It is an effective pattern because it takes turns to build the process. Make sure each member alternates between writing the tests and passing the tests. This will become a Ping Pong anti-pattern if the same programmer is always writing the tests and the same programmer is always making the tests pass.
Here, in this type of pairing no particular approach will be followed. It is a free-flowing, turn-taking process between the driver and the navigator. It has no-structure but can help through well-matched pairs move faster. However, the pairs that have different styles will struggle with the lack of structure in it.
PROS OF PAIR PROGRAMMING:
1.Increased code quality.
2.Less mistakes and bugs.
4.Improved team spirit.
CONS OF PAIR PROGRAMMING:
1.Cost is higher:
Two people working on a single initiative may seem like a waste of valuable resources and time. Indeed, pair programming won’t be able to complete the project in half of the time. You pay in more costs upfront, but you can only recover your investment over the lifetime of the project, since you will be spending less time maintaining the codebase.
Pair Programming is not sustainable to be used always. It takes around 2-2.5 hours of pair programming.