Test-based development and pair programming

I am on a team where I am trying to convince my teammates to accept TDD (since I saw how he worked on my previous team and the setup is similar). In addition, my personal belief is that, at least in the beginning, it really helps if both TDD and Pair Programming are performed together. Thus, two inexperienced (in TDD) developers can help each other, discuss which tests to write and make good progress.

My manager, on the other hand, feels that if we immediately introduce two new development practices in a team, there is a good chance that both can fail. So, he wants to be a little more conservative and introduce anyone.

How I convince him that both of them are complementary, not orthogonal. Or am I wrong?

+6
tdd extreme-programming pair-programming
source share
9 answers

I'm not sure that more people who don’t know what they are doing in TDD will help. He will descend quickly in both of you. Parsing a topic, or both of you are arguing about what TDD is.

I think you better get someone from the team to become an evangelist by this technique (someone goes and reads TDD, someone goes and reads about pair programming), and then these people promote and test those things. Yes, both can happen at the same time, but they should not be used in the entire project team. You may have a small group of your team that does pair programming and then share their experiences.

+13
source share

A pair of progaming is effective in learning new practices, especially TDD

So you can have both with a compromise. Do it in a flexible way, gradually. Take pair programming first. It is easier. All practices after pair programming will become much easier to learn and will be adopted by the team faster and with greater consistency. Para-programming is one of the first, if not the first practice to be adopted. Make sure it is done efficiently. The following is a description of how to do pair programming.

Paired programming is one of the most effective practices that a development team can use when developing software. Pairing occurs with two developers who are actively developing history using a single computer and keyboard. Managers fear that using pair programming will double the cost of programming. At first glance, it is clear why they might think that - in the end - two developers will be asked to work together on the same task. In practice, however, Agile teams using this development technology have found that a small increase in initial development costs (15% according to a study by the University of Utah) is more than offset by a reduction in defects, shorter and less expensive cycle testing and reduced need in supporting production.

Although it might seem counterintuitive that programmers working together and working together improve performance, there are a number of reasons why this technique really works (think of the old adage: “Two heads are better than one.”) Here's why:

  • Improved Quality - Pairing encourages code viewing. Many errors are caught when they are printed. Interfacing means continuous code review by two people who are committed to code quality and working together to identify and correct errors at any time. A study by the University of Utah showed that the final number of defects found in code was reduced by an average of 15% for code written in pairs.
  • Less time spent "stuck" - programming is difficult. Often, developers struggle to find a solution and spend more time than they should get stuck. Having a partner to brainstorm ideas and agree to seek help if necessary reduces the amount of unproductive time spent trying to find a solution.
  • Less time spent on distractions - a developer is less likely to spend time on personal phone calls or surfing the Internet or email holidays when he or she works with a partner.
  • Two problems apply to the problem. Different levels of experience, different styles of problem solving, various supporting skills increase the chances of solving a problem faster. A study by the University of Utah also revealed a better overall design and shorter code length for software written in pairs.
  • Less fear of the unknown - when connecting with another developer it is easier to solve a problem or try to access new technology than when working alone. They also get a much better understanding of the whole application over time. In the end, the project ends up with the fact that many people understand every part of the system as a result of pairing.
  • Less likely to build in the field - often developers are willing to add functionality that is not described in the requirements. When working with a couple, the second developer is more likely to support the work of his partner.
  • Improved team dynamics. Because of the pairing approach, people learn to work together. They speak more often and experience a better flow of information. As a result, group dynamics are improving. In fact, we found that the best team building experience is working together to create software that your client is excited about. Everyone loves to be part of a successful team.
  • Elimination of silos of knowledge. Domain knowledge, code or practice knowledge is quickly spread through a team and a couple of developers with each other based on rotation.

Once the team is comfortable with pairing, then take the TDD. Following:

Test-Driven Development (TDD) is software development for software development, consisting of a short burst of development, where first a new test case is written that includes the required improvement or new functionality, then the production code needed to pass the test is implemented, and finally , the software is being reorganized to make changes. Having tests prior to actual development provides quick feedback after any changes. Practitioners emphasize that test-based development is a software development method, not just a testing method. Test-based development is a powerful practice and a major factor in reducing defects discovered later in the life cycle. The new team is strongly encouraged to combine with an experienced TDD practitioner or otherwise receive TDD coaching.e

Test-based development requires that an automated unit test, which defines the requirements of the code, be written before every aspect of the code itself. These tests contain statements that are either true or false. Running tests provides quick confirmation of the correct behavior as the code evolves and reorganizes. XUnit-based test frameworks provide a mechanism for creating and running sets of automated test cases. Test-based development cycle. The following sequence is based on the book Test-Based Development using an example that many consider to be the canonical source code for the concept in its current form.

  • Write a test. In test development, each new story begins with writing a test. This test will fail because it was written before the function was implemented. To write a test, the developer must clearly understand the specification and requirements of this function. This can be achieved through "History Maps" with eligibility criteria to indicate when requirements are met. It may also imply an invariant or modification of an existing test. This is a distinctive feature of test development compared to writing unit tests after writing code: it forces the developer to focus on requirements before writing code, a subtle but important difference.
  • Run all the tests and check if the new one worked. This confirms that the test harness is working correctly and that the new test does not fail erroneously without requiring any new code. The new test should also fail for the expected reason. This step itself tests the test itself, negatively: it excludes the possibility that a new test will always pass, and therefore will be useless.
  • Write the code. The next step is to write code that will pass the test. The new code written at this stage will not be ideal and may, for example, pass the test in an inelegant way. This is acceptable because the next steps will improve and hone it. It is important that the written code is intended only for passing the test; no further (and therefore unchecked) functionality should be predicted and "resolved" at any stage.
  • Run automated tests and make sure they are successful. If all the test cases pass now, the programmer can be sure that the code meets all the tested requirements. This is a good point to start the last stage of the cycle.
  • Refactoring code. Now the code can be cleaned as needed. By re-running test cases, the developer can be sure that refactoring will not harm any existing functionality. The concept of eliminating duplication is an important aspect of any software. In this case, however, this also applies to removing any duplication between the test code and the production code - for example, magic numbers or lines that were repeated in both cases to pass the test in step 3.

Repeat

Starting with another new test, the loop repeats to advance functionality. The size of the steps can be as small as the developer, or get larger if he / she feels more confident. If the code written to run the test quickly does not do this, the step size may be too large, and perhaps smaller control steps should be used instead. When using external libraries, it is important not to make increments that are so small as to effectively simply test the library yourself, if there is no reason to believe that the buggy library is not full enough to satisfy all needs, the main program is written.

Development style There are various aspects of using test development, for example, the principles of "Keep It Simple, Stupid" (KISS) and "You Is It Gonna Need It" (YAGNI). By focusing on writing only the code necessary to pass the tests, projects can be cleaner and more understandable than other methods. For test-based development, a programmer must first skip test cases. The idea is to make sure the test really works and can catch the error. Once this is shown, a normal cycle will begin. This was invented by the “Test Mantra of Development,” known as red / green / refactor, where red means failure and green means passage. Test-based development constantly repeats the steps of adding test cases that fail, pass them along, and refactor. Obtaining the expected test results at each stage strengthens the mental model of the code programmer, increases confidence and improves productivity.

+9
source share

You are absolutely right that pair programming will help a lot when learning something new. I agree with you that you must make great strides towards both.

Perhaps the best way to lay out for your manager does not mean that you are asking to introduce these two new things at the same time. Instead, suppose you think that the most effective way to get started with TDD is, although doing the work, to take only two developers as a “TDD investigation team” and get them to work together to create the appropriate tools, learn the methods, check them out and find out what you need to do to apply them in your environment. After you succeed, and you have two people who have a little experience with him, then separate them, and each will sit down with the other developer for several days to speed up the work of the other developer using new methods. Repeat until all developers recognize TDD.

+2
source share

You will not convince. Tell him how you think they work together, maybe there is some evidence to support this, and let him decide. If you need to convince everyone that this is a good idea, I bet that no one will treat her too well. Full opposition.

+1
source share

Personally, I found that pair programming works best with one experienced and one inexperienced.

Those. I would like to strive for the difference in skills / experience of programmers, and not to be equal.

the more experienced gets more out of this explanation and is forced to structure thoughts, while the inexperienced gets a chance to drop ideas and pick up “best practices”.

as for TDD, I'm a big fan. Again, exp helps the inexperienced, because it helps to really identify the testing point. Those. you don’t want to check everything completely ... this adds focus. Often I find that people write tests without focusing on what they are trying to achieve.

Unit tests are important ... after all, some employees will not be there in 2 years. How can you modify existing code if there is nothing to test its function?

+1
source share

Well, depending on the manager, you can point out some arguments in the XP literature that these methods are interdependent. For example, if you do not have solid unit tests, do not refactor mercilessly.

I would suggest that you approach it in stages, since pairing would only be for the purpose of determining TDD, like any joint efforts on a new complex problem, and not that "all production developments will be carried out in pairs."

0
source share

While one practice does not require another, there is a “hidden” way to enter as little at a time.

Start with the goal of implementing TDD using one of the available xUnit frameworks. Find a compatible employee and ask if they are ready to work with you about an hour a day. "Sean, I'm trying to use this new tool, will you help me to do everything right?" works very well.

After a couple of days with Sean, repeat with Susan ...

0
source share

Do it anyway. If the manager catches you mating, say the magic words "Code Review"
Assumption: Obviously, the couple should be disciplined / focused and create working code at the end of the session.

0
source share

All Articles