pieces in place; and when called will seem like it functions。 The echo part es in when the
end piece of functionality is called and it returns the data that was sent to it。 In essence; the end
piece is acting like an echo。 The cleverness behind the echo is that it requires no implementa
tion; yet it demonstrates the plete flow of data and whether that data flow is workable。
The echo program is not a final program。 The echo program is a temporary solution for an
intermediate goal。 When building an application with intermediate goals; you are using an
iterative development technique。 The iterations are not visible to your other team members
and are pletely private。 However; the iterations will keep you focused on solving a problem;
rather than trying to implement a large piece of code that you will not be able to fully test for
a while。
Test…driven development; for the most part; is a bottom…up development approach。 You
develop a core piece of functionality; test it; and then write code that uses the tested piece of
…………………………………………………………Page 275……………………………………………………………
CH A PT E R 1 0 ■ L E A R N I N G A B O U T P E R S IS T E N CE 253
functionality。 But sometimes you need to develop in a top…down fashion。 I typically develop
code top…down when I am trying to nail down an overall architecture。 The problem with devel
oping top…down is that you don’t yet have the bottom code。 In other words; you are writing
code with no working code。 So that your code does have some meaning; you develop an echo。
The echo solves the problem of working code and allows you to focus on getting the individual
pieces to fit together。 Once the pieces are working; and the echo was successful; you can start
filling in the implementations。 Some developers call the echo a mock implementation。
Here; I’ll explain developing the sample application by assembling individual pieces in a
top…down manner; focusing on getting a single echo implemented。 Then once the overall flow
is plete; the individual pieces will be implemented pletely。 Figure 10…2 illustrates
a plete architecture for the lottery…prediction program; including the pipeline for the
TextProcessor console application。
Figure 10…2。 Architecture of a reader/writer application using a general assembly
Reading and Writing to a Stream
For developing the lottery…prediction application; we’ll use a piece of bootstrap code to initiate
the reading and writing library; which then calls the specific implementation。 Bootstrap code is
code that does not actually perform the processing; but is responsible for setting up and initi
ating another piece of source code that will do the processing。
This is the same sort of architecture as we set up in Chapter 8’s example; for the applica
tion to control the lights of a building。 In that case; the controller was a generic piece of software
that called an interface; but did not know about the individual implementations。 The focus
there was on developing the room implementations; and the lighting controller was left as a
nebulous to…do task。 Here; we’ll go through the creation of a plete working application;
including the controller and implementation。 Note this chapter is light on testing routines;
both for brevity and because one of the exercises at the end of the chapter is for you to e up
with a testing plan。
We want to be able to process the following mand line。
type lotto。txt | TextProcessor。exe
…………………………………………………………Page 276……………………………………………………………
254 CH AP T E R 1 0 ■ L E A R N I N G A B OU T P E R S IS TE N CE
If TextProcessor。exe cannot read the data from the pipe; an exception will be thrown at
the console level; indicating that the piped data was not read。
■Note For the application to work; the lotto。txt and TextProcessor。exe files must be in the same
directory。 By default; TextProcessor。exe is in the 'Visual Studio project'bindebug directory。
Copy TextProcessor。exe into the lotto。txt directory; or vice versa; or you could even copy them both
into another directory。
In the architecture of TextProcessor; the bootstrap code is in the ReaderWriter project。
The TextProcessor console application must call the bootstrap code and instantiate a local
type that has implemented the IProcessor interface。 The Main() method of TextProcessor is
implemented as follows (this is the best time to add a reference to the ReaderWriter project by
right…clicking TextProcessor and choosing Add Reference Projects ReaderWriter):
Imports ReaderWriter
Public Module Module1
Sub Main(ByVal args As String())
Bootstrap。Start(args; New LottoTicketProcessor())
End Sub
End Module
TextProcessor。Main() passes all of the given arguments (contained in the args array) to
the actual processing routine (Bootstrap。Start())。 The LottoTicketProcessor class imple
ments the IProcessor interface and will serve for the temporary purpose of echoing data。 The
IProcessor interface is defined in the ReaderWriter project as follows:
Public Interface IProcessor
Function Process(ByVal input As String) As String
End Interface
The IProcessor interface has a single method Process(); which accepts a string to be
processed; and the return value is the processed string。
The implementation of LottoLibrary。LottoTicketProcessor is as follows (remember to
add a referenc
小说推荐
- oracle从入门到精通(PDF格式)
- -Page 1-Oracle 从入门到精通-Page 2-资源来自网络,仅供学习 Oracle 从入门到精通一、SQL 8
- 最新章:第37章
- C语言游戏编程从入门到精通(PDF格式)
- -Page 1-Page 2-Page 3-Page 4-Page 5-Page 6-Page 7-Page 8-Page 9-Page 10-Page 11-Page 12-Page 13-Page 14
- 最新章:第4章
- Java编程思想第4版[中文版](PDF格式)
- -Page 1-Page 2《Thinking In Java》中文版作者:Bruce Eckel主页:http/BruceEckel.编译:Trans Bot主页:http/memberease~transbot致谢-献给那些直到现在仍在孜孜不倦创造下一代计算机语言的人们!指导您利用万维网的语言进
- 最新章:第295章
- 深入浅出MFC第2版(PDF格式)
- -Page 1-Page 2-山高月小山高月小 水落石出水落石出山高月小山高月小 水落石出水落石出-Page 3-深入淺出MFC(第版 使用Visual C 5.0 MFC 4.2)Dissecting MFC(Second Edition Using Visual C 5.0 MFC 4.2)侯俊
- 最新章:第309章
- VC语言6.0程序设计从入门到精通
- -Page 1-Visual C 6.0 程序设计从入门到精通求是科技 王正军 编著
- 最新章:第136章
- SQL 21日自学通(V3.0)(PDF格式)
- -Page 1-SQL 21 日自学通(V1.0 翻译人 笨猪目录目录 1译者的话 14第一周概貌 16从这里开始 16
- 最新章:第170章
- 2008年青年文摘精编版
- 作者:中国青年出版社“初恋”的惩罚.作者:凡 凡 文章来源《真情》2005年第4期 点击数:6608 更新时间:2005-6-5过了年,我就十八岁了。离高考只剩下四个多月了。这一段,班里的男女生相互间递纸条、写情书、约会等地下活动慢慢的多了起来。我这个“尖子生”也突然感到了不安、慌乱,并且自责。不知
- 最新章:第230章
- JMS简明教程(PDF格式)
- -Page 1-JMS1.1规范中文版卫建军2007‐11‐22-Page 2
- 最新章:第28章
- SQL语言艺术(PDF格式)
- -Page 1-SQLSSQQLL语言艺术内容介绍本书分为12章,每一章包含许多原则或准则,并通过举例的方式对原则进行解释说明。这些例子大多来自于实际案例,对九种SQL经典查询场景以及其性能影响讨论,非常便于实践,为你数据库应用维护人员阅读。资深 SQL 专家 Stéphane Faroult倾力打
- 最新章:第27章