Dedicated to Ashley & Iris




НазваниеDedicated to Ashley & Iris
страница7/71
Дата24.09.2012
Размер3.51 Mb.
ТипДокументы
1   2   3   4   5   6   7   8   9   10   ...   71

So Why Bother TFPing a GUI?


Why do we insist on doing the impossible? No matter how thin you think your GUI Layer is, and how much logic you push out into the Representation Layer, the simple fact is bugs spontaneously generate in code without tests. TFP will illustrate this effect by pushing the defect rate down everywhere that tests go. Your program’s testless parts will experience a higher defect rate, and will stick out like sore thumbs.

Many GUIs, including some of mine, will grow and live happy lives without any tests. We could easily follow the policy “Ain’t broke don’t fix it.” We could decide not to write tests for some of our modules until we need to. Unlike a Logic Layer, faults in a GUI are trivial to find and fix. We could decide to “Capture Bugs with Tests”, and only write tests after we detect bugs. So the Agile aphorism “You Aren’t Gonna Need it” might lead us to defer labor, hoping to permanently avoid it.

That strategy has one major flaw, called “Activation Energy”. If a module already has tests, new tests are very easy to write. The activation energy is low. However, modules without tests can make new ones very hard to write. (Hence entire books on the subject, such as Working Effectively with Legacy Code by Mike Feathers.) The activation energy is much higher.

The larger a module grows without tests, the higher its Activation Energy gets. When you receive defect reports, the energy required to “just fix them” is lower than the energy required to retrofit a test rig, capture the bugs with tests, and then kill them. So each time you “just fix them”, and put off that labor, defects grow more likely, the odds of putting off the labor gets higher, the risks of debugging go up, and the deferred labor gets harder.

Tests are the only aspect of Agile development that you are going to need.

Authoring


All new modules, including GUIs, must start with tests. That’s the best way to learn where the trouble spots and nasty surprises are, to ensure that test suites grow, with their modules, and remain ready to assist in all advanced development.

However, not all GUI features need tests. Much of GUI development is authoring—painting controls, positioning them, coloring them, etc. If you don’t intend to refactor the logic supporting trivial graphic details, author the graphic detail directly.

This book uses the verb “author” to mean, “Skip the tests, and just type this part in.”

This book also explores advanced techniques to escalate the review of graphic details, in bulk, decoupled from their applications. That reduces the risks from faults in authored details.

But Aren’t All GUIs Different?


How can the same strategy work on all of them?

All GUIs decouple the user from a program using an event queue. This routes input events, including commands to repaint the screen, into event handlers. Some handlers live in your GUI Toolkit, and some you declare in the GUI Layer and customize.

GUIs use three general systems. When the user invokes or uncovers a window, its Paint() event handler sends hardware commands to display the window on your monitor. A control is a unit of animation managed by your GUI Toolkit, so you generally don’t need to worry about its Paint() event. A script is a batch of commands that generate or process controls, then submit them to an event queue.

Chapter 3: GUI Architecture, on page 27, explains these systems in relation to your application and tests. Each system yields to specific test attacks. Because they all use an event queue, the attacks are all different aspects of the same strategy.

Conclusion


Test-First Programming demands obedience from code. GUIs are persnickety, unruly, and ornery.

The first technique splits a project’s GUI modules into a thin GUI Layer and a thick but GUI-free Representation Layer. That intermediates between the Logic and GUI Layers, exposing the maximum interface to aggressive tests.

But we can’t completely avoid some effort. A thick Representation Layer does not absolve even the simplest GUI of the need for exploratory tests. A simple GUI might turn complex sooner than you can retrofit a test rig. This book describes how to write advanced GUI controls that supplement the ones provided by your GUI Toolkit.

Instead of neglecting GUI tests, or researching them forever, you need a strategy that forces discovery of GUI test issues, and right-sizes the amount of test infrastructure that your application’s GUI will need.
1   2   3   4   5   6   7   8   9   10   ...   71

Похожие:

Dedicated to Ashley & Iris iconDedicated to Ashley & Iris

Dedicated to Ashley & Iris iconAbramovitz, Janet N., and Ashley T. Mattoon. 1999

Dedicated to Ashley & Iris iconPlastics and the Environment. Hoboken. N. J. Wiley-Interscience. Ashley, S. 2002

Dedicated to Ashley & Iris iconGilliland home is dedicated

Dedicated to Ashley & Iris iconCitations Acknowledging or using iris-related facilities and Data As of August 2010 Please send corrections and/or additions to

Dedicated to Ashley & Iris iconDedicated to Jerry Lefcourt, Lawyer and Brother

Dedicated to Ashley & Iris iconFree to download magazine dedicated to Commodore computers

Dedicated to Ashley & Iris iconMorning session I: Dedicated to Prof. A. Acrivos, “Suspensions and particulates”

Dedicated to Ashley & Iris icon08: 30 Registration 09: 00 Welcome Remarks Morning session I: Dedicated to Prof. A. Acrivos, “Suspensions and particulates”

Dedicated to Ashley & Iris iconThe Culture of Irises in the United States Iris Culture for the Mountain and Plains Region, D. M. Andrews 5

Разместите кнопку на своём сайте:
Библиотека


База данных защищена авторским правом ©lib.znate.ru 2014
обратиться к администрации
Библиотека
Главная страница