|
Agile Principles, Patterns, and Practices in C# Authors: Robert M.C., Micah M Published year: 2006 Pages: 34-37/272 |
Serendipitous ArchitectureNote the pressure that the acceptance tests placed on the architecture of the payroll system. The very fact that we considered the tests first led us to the notion of an API for the functions of the payroll system. Clearly, the UI will use this API to achieve its ends. Note also that the printing of the paychecks must be decoupled from the Create Paychecks function. These are good architectural decisions. Figure 4-3. Sample acceptance test
|
ConclusionThe simpler it is to run a suite of tests, the more often those tests will be run. The more the tests are run, the sooner any deviation from those tests will be found. If we can run all the tests several time a day, then the system will never be broken for more than a few minutes. This is a reasonable goal. We simply don't allow the system to backslide. Once it works to a certain level, it never backslides to a lower level. Yet verification is only one of the benefits of writing tests. Both unit tests and acceptance tests are a form of documentation. That documentation is compilable and executable and therefore accurate and reliable. Moreover, these tests are written in unambiguous languages that are readable by their audience. Programmers can read unit tests because they are written in their programming language. Customers can read acceptance tests because they are written in a simple tabular language. Possibly the most important benefit of all this testing is the impact it has on architecture and design. To make a module or an application testable, it must also be decoupled. The more testable it is, the more decoupled it is. The act of considering comprehensive acceptance and unit tests has a profoundly positive effect on the structure of the software. |
Bibliography[Jeffries2001] Ron Jeffries, Extreme Programming Installed , Addison-Wesley, 2001. [Mackinnon2000] Tim Mackinnon, Steve Freeman, and Philip Craig, "Endo-Testing: Unit Testing with Mock Objects," in Giancarlo Succi and Michele Marchesi, Extreme Programming Examined , Addison-Wesley, 2001. [Mugridge2005] Rick Mugridge and Ward Cunningham, Fit for Developing Software: Framework for Integrated Tests , Addison-Wesley, 2005. |
Chapter 5. Refactoring
Jennifer M. Kohnke
This chapter is about human attention, about paying attention to what you are doing and making sure that you are doing your best. It is about the difference between getting something to work and getting something right. It is about the value we place in the structure of our code. In Refactoring , his classic book, Martin Fowler defines refactoring as "the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure." [1] But why would we want to improve the structure of working code? What about "If it's not broken, don't fix it!"?
Every software module has three functions. First is the function it performs while executing. This function is the reason for the module's existence. The second function of a module is to afford change. Almost all modules will change in the course of their lives, and it is the responsibility of the developers to make sure that such changes are as simple as possible to make. A module that is difficult to change is broken and needs fixing, even though it works. The third function of a module is to communicate to its readers. Developers who are not familiar with the module should be able to read and understand it without undue mental gymnastics. A module that does not communicate is broken and needs to be fixed. What does it take to make a module easy to read and easy to change? Much of this book is dedicated to principles and patterns whose primary goal is to help you create modules that are flexible and adaptable. But it takes something more than just principles and patterns to make a module that is easy to read and change. It takes attention. It takes discipline. It takes a passion for creating beauty. |
|
Agile Principles, Patterns, and Practices in C# Authors: Robert M.C., Micah M Published year: 2006 Pages: 34-37/272 |