Implementation level

The design of the implementation level requires the most effort so that you can keep the code as good as it can be. There are several practices you need to adopt, such as the following:

  • Test-driven development: At the implementation level, we must practice test-driven development. This is critical for an Agile project because we rely on these unit tests to make sure that the code we write runs correctly after refactoring. We also use unit tests as the client of the source code to help us improve the code design, make it decoupled, and also increase code quality. And when we have test cases to verify our code, we can do frequent refactoring to clean up the mess in the code so that the system won't suffer from all those symptoms we talked about.
  • Acceptance tests: Besides unit tests, we should also write acceptance tests to verify the details of user stories specified by the customer. These acceptance tests need to be able to run repeatedly. They provide a higher level of verification than the unit tests. Together, unit tests and acceptance tests act to verify the implementation level design and provide confidence during refactoring.
  • Refactoring: Another practice, which we mentioned several times, is refactoring. It is like reorganizing the furniture of your house or doing housekeeping to prevent things from becoming messy. Refactoring is a technique to improve your design by changing the code in order to apply a design principle or use a design pattern whenever it is necessary. That is, when you write code, you start from simple and only write enough code to make it pass the test cases. No more, no less. In this way, you keep a simple design in the implementation level, and only when there is a change or a smell in the code do you refactor it.
  • Focus on current stories: When doing code design at the implementation level, you should focus on the user stories of the current sprint and design the code to be as good as it can be. Don't worry too much about future user stories. You can keep them in mind, but do not write code for them. Here are the reasons why:
    • Future stories might be changed or discarded. In such cases, the code written for future stories would bring needless complexity into the design.
    • You can write them when the time comes. You are not at much of an advantage by writing them earlier. On the contrary, you're taking risks when doing that.

To sum this up, in practice, we create high-level architecture level designs and abstraction level designs. At the implementation level, we do the following:

  • We adopt test-driven development practice and write acceptance tests to detect the problem of the code
  • We apply design principles to find out code smells
  • We apply appropriate design patterns to solve the problem through refactoring

So, Agile code design is more of a process than a set of design documents or an event. Robert C. Martin defined it as follows:

It's the continuous application of principles, patterns, and practices to improve the structure and readability of the software. It is the dedication of keeping the design of the system as simple, clean, and expressive as possible at all times.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.186.167