100% found this document useful (8 votes)
35 views56 pages

(Ebook) Adaptive Code Via C#: Agile Coding With Design Patterns and SOLID Principles by Gary McLean Hall ISBN 9780735683204, 0735683204 PDF Download

The document provides information about various ebooks related to software development, design patterns, and agile methodologies, including titles like 'Adaptive Code via C#' and 'JavaScript Patterns.' Each entry includes the book's title, author, ISBN, and a link for downloading. It also features a table of contents for 'Adaptive Code via C#,' outlining its focus on agile foundations and SOLID principles.

Uploaded by

sgffedsqwq2130
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
35 views56 pages

(Ebook) Adaptive Code Via C#: Agile Coding With Design Patterns and SOLID Principles by Gary McLean Hall ISBN 9780735683204, 0735683204 PDF Download

The document provides information about various ebooks related to software development, design patterns, and agile methodologies, including titles like 'Adaptive Code via C#' and 'JavaScript Patterns.' Each entry includes the book's title, author, ISBN, and a link for downloading. It also features a table of contents for 'Adaptive Code via C#,' outlining its focus on agile foundations and SOLID principles.

Uploaded by

sgffedsqwq2130
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

(Ebook) Adaptive Code via C#: Agile coding with

design patterns and SOLID principles by Gary McLean


Hall ISBN 9780735683204, 0735683204 download pdf

https://ebooknice.com/product/adaptive-code-via-c-agile-coding-with-
design-patterns-and-solid-principles-5032562

Visit ebooknice.com today to download the complete set of


ebook or textbook
We have selected some products that you may be interested in
Click the link to download now or visit ebooknice.com
for more options!.

(Ebook) JavaScript Patterns: Build Better Applications with


Coding and Design Patterns by Stefanov, Stoyan ISBN
9780596806750, 0596806752

https://ebooknice.com/product/javascript-patterns-build-better-
applications-with-coding-and-design-patterns-55886614

(Ebook) Agile software development: principles, patterns, and


practices by Martin, Robert C ISBN 9781292025940, 9781351471510,
1292025948, 1351471511

https://ebooknice.com/product/agile-software-development-principles-
patterns-and-practices-21976766

(Ebook) Pro WPF and Silverlight MVVM: Effective Application


Development with Model-View-ViewModel by Gary McLean Hall ISBN
9781430231622, 1430231629

https://ebooknice.com/product/pro-wpf-and-silverlight-mvvm-effective-
application-development-with-model-view-viewmodel-1722038

(Ebook) Pro WPF and Silverlight MVVM: Effective Application


Development with Model-View-ViewModel by Gary McLean Hall ISBN
9781430231622, 9781430231639, 1430231629, 1430231637

https://ebooknice.com/product/pro-wpf-and-silverlight-mvvm-effective-
application-development-with-model-view-viewmodel-42323434
(Ebook) MASTERING JAVASCRIPT DESIGN PATTERNS: create scalable
and reliable applications with advanced Javascript design
patterns using reliable code by Tomas Corral Cosas ISBN
9781788627580, 178862758X
https://ebooknice.com/product/mastering-javascript-design-patterns-create-
scalable-and-reliable-applications-with-advanced-javascript-design-
patterns-using-reliable-code-9992610

(Ebook) The easiest way to learn design patterns: With C# code


samples using .NET 6 templates by Fiodar Sazanavets ISBN
9798801124841, 8801124848

https://ebooknice.com/product/the-easiest-way-to-learn-design-patterns-
with-c-code-samples-using-net-6-templates-47443310

(Ebook) Agile Software Development, Principles, Patterns, and


Practices by Robert Martin ISBN 9781292025940, 1292025948

https://ebooknice.com/product/agile-software-development-principles-
patterns-and-practices-11074242

(Ebook) Functional Design: Principles, Patterns, and Practices


(Robert C. Martin) by Martin, Robert ISBN 9780138176396,
0138176396

https://ebooknice.com/product/functional-design-principles-patterns-and-
practices-robert-c-martin-55621382

(Ebook) Java Design Patterns: A tour of 23 gang of four design


patterns in Java by Vaskaran Sarcar ISBN 9781484218013,
1484218019

https://ebooknice.com/product/java-design-patterns-a-tour-of-23-gang-of-
four-design-patterns-in-java-5470384
From the Library of Ida Schander
Adaptive Code via C#:
Agile coding with
design patterns and
SOLID principles

Gary McLean Hall

From the Library of Ida Schander


PUBLISHED BY
Microsoft Press
A division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399
Copyright © 2014 by Gary McLean Hall. All rights reserved.
No part of the contents of this book may be reproduced or transmitted in any form or by any means without
the written permission of the publisher.
Library of Congress Control Number: 2014943458
ISBN: 978-0-7356-8320-4

Printed and bound in the United States of America.

First Printing

Microsoft Press books are available through booksellers and distributors worldwide. If you need support related
to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of
this book at http://aka.ms/tellpress.

This book is provided “as-is” and expresses the author’s views and opinions. The views, opinions and information
expressed in this book, including URL and other Internet website references, may change without notice.

Some examples depicted herein are provided for illustration only and are fictitious. No real association or
connection is intended or should be inferred.

Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks
of the Microsoft group of companies. All other marks are property of their respective owners.

Acquisitions Editor: Devon Musgrave


Developmental Editor: Devon Musgrave
Project Editor: Devon Musgrave
Editorial Production: Online Training Solutions, Inc. (OTSI)
Technical Reviewer: Jeremy Johnson
Copyeditor: Kathy Krause (OTSI)
Indexer: Krista Wall (OTSI)
Cover: Twist Creative • Seattle and Joel Panchot

From the Library of Ida Schander


For Amelia Rose
—Gary McLean Hall

From the Library of Ida Schander


This page intentionally left blank

From the Library of Ida Schander


Contents at a glance

Introduction xv

PART I AN AGILE FOUNDATION

CHAPTER 1 Introduction to Scrum 3


CHAPTER 2 Dependencies and layering 43
CHAPTER 3 Interfaces and design patterns 93
CHAPTER 4 Unit testing and refactoring 125

PART II WRITING SOLID CODE

CHAPTER 5 The single responsibility principle 169


CHAPTER 6 The open/closed principle 207
CHAPTER 7 The Liskov substitution principle 217
CHAPTER 8 Interface segregation 251
CHAPTER 9 Dependency injection 281

PART III ADAPTIVE SAMPLE

CHAPTER 10 Adaptive sample: Introduction 325


CHAPTER 11 Adaptive sample: Sprint 1 337
CHAPTER 12 Adaptive sample: Sprint 2 365

Appendix A: Adaptive tools 379


Appendix B: GitHub code samples online

Index 387

About the author 403

From the Library of Ida Schander


This page intentionally left blank

From the Library of Ida Schander


Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

PART I AN AGILE FOUNDATION

Chapter 1 Introduction to Scrum 3


Scrum versus waterfall. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Roles and responsibilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7


Product owner. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Scrum master. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Development team. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Pigs and chickens. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Artifacts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
The Scrum board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Charts and metrics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Backlogs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

The sprint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Release planning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Sprint planning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Daily Scrum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Sprint demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Sprint retrospective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Scrum calendar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Problems with Scrum and Agile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37


Maladaptive code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

What do you think of this book? We want to hear from you!


Microsoft is interested in hearing your feedback so we can continually improve our
books and learning resources for you. To participate in a brief online survey, please visit:

microsoft.com/learning/booksurvey

vii

From the Library of Ida Schander


Chapter 2 Dependencies and layering 43
The definition of dependency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
A simple example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Modeling dependencies in a directed graph. . . . . . . . . . . . . . . . . . . . . . 51

Managing dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Implementations versus interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
The new code smell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Alternatives to object construction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
The Entourage anti-pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
The Stairway pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Resolving dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Dependency management with NuGet. . . . . . . . . . . . . . . . . . . . . . . . . . 77

Layering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Common patterns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Cross-cutting concerns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Asymmetric layering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Chapter 3 Interfaces and design patterns 93


What is an interface? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Explicit implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Adaptive design patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102


The Null Object pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The Adapter pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
The Strategy pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Further versatility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113


Duck-typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Mixins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Fluent interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

viii Contents

From the Library of Ida Schander


Chapter 4 Unit testing and refactoring 125
Unit testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Arrange, Act, Assert. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Test-driven development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
More complex tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

Refactoring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Changing existing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
A new account type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

PART II WRITING SOLID CODE

Chapter 5 The single responsibility principle 169


Problem statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Refactoring for clarity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Refactoring for abstraction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

SRP and the Decorator pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184


The Composite pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Predicate decorators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Branching decorators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Lazy decorators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Logging decorators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Profiling decorators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Asynchronous decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Decorating properties and events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Using the Strategy pattern instead of switch. . . . . . . . . . . . . . . . . . . . . . . . 204

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

Contents ix

From the Library of Ida Schander


Chapter 6 The open/closed principle 207
Introduction to the open/closed principle. . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
The Meyer definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
The Martin definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Bug fixes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Client awareness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Extension points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


Code without extension points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Virtual methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Abstract methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Interface inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
“Design for inheritance or prohibit it”. . . . . . . . . . . . . . . . . . . . . . . . . . 212

Protected variation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213


Predicted variation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
A stable interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Just enough adaptability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

Chapter 7 The Liskov substitution principle 217


Introduction to the Liskov substitution principle. . . . . . . . . . . . . . . . . . . . . . 217
Formal definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
LSP rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

Contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Preconditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Postconditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Data invariants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Liskov contract rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Code contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

Covariance and contravariance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239


Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Liskov type system rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

x Contents

From the Library of Ida Schander


Chapter 8 Interface segregation 251
A segregation example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
A simple CRUD interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Caching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Multiple interface decoration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

Client construction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263


Multiple implementations, multiple instances. . . . . . . . . . . . . . . . . . . 263
Single implementation, single instance. . . . . . . . . . . . . . . . . . . . . . . . . 266
The Interface Soup anti-pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Splitting interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268


Client need. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Architectural need. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Single-method interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

Chapter 9 Dependency injection 281


Humble beginnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The Task List application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Constructing the object graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Inversion of Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Beyond simple injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
The Service Locator anti-pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Illegitimate Injection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
The composition root. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Convention over configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

Contents xi

From the Library of Ida Schander


PART III ADAPTIVE SAMPLE

Chapter 10 Adaptive sample: Introduction 325


Trey Research. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
The team. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
The product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

Initial backlog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328


Finding stories in prose. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Story point estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

Chapter 11 Adaptive sample: Sprint 1 337


Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

“I want to create rooms for categorizing conversations.”. . . . . . . . . . . . . . . 340


The controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
The room repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

“I want to view a list of rooms that represent conversations.”. . . . . . . . . . . 349

“I want to view the messages that have been sent to a room.“ . . . . . . . . . 353

“I want to send plain text messages to other room members.”. . . . . . . . . 356

Sprint demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357


First demonstration of Proseware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

Sprint retrospective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358


What went well?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
What went badly?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Things to change?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Things to keep? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Surprises?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

xii Contents

From the Library of Ida Schander


Chapter 12 Adaptive sample: Sprint 2 365
Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

“I want to send markdown that will be correctly formatted.”. . . . . . . . . . . 367

“I want to filter message content so that it is appropriate.”. . . . . . . . . . . . . 370

“I want to serve hundreds of users concurrently.”. . . . . . . . . . . . . . . . . . . . . 373

Sprint demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

Sprint retrospective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376


What went well?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
What went badly?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Things to change?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Things to keep? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Surprises?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

Appendix A: Adaptive Tools 379


Appendix B: GitHub code samples online

Index 387

About the author 403

What do you think of this book? We want to hear from you!


Microsoft is interested in hearing your feedback so we can continually improve our
books and learning resources for you. To participate in a brief online survey, please visit:

microsoft.com/learning/booksurvey

Contents xiii

From the Library of Ida Schander


This page intentionally left blank

From the Library of Ida Schander


Introduction

T he first words of the title of this book, Adaptive Code, provide a good description
of the outcome of applying the principles in the book: the ability of code to adapt
to any new requirement or unforeseen scenario while avoiding significant rework. The
aim of this book is to aggregate into one volume many of the current best practices in
the world of C# programming with the Microsoft .NET Framework. Although some of
the content is covered in other books, those books either focus heavily on theory or are
not specific to .NET development.

Programming can be a slow process. If your code is adaptive, you will be able to
make changes to it more quickly, more easily, and with fewer errors than you would
if you were working with a codebase that impedes changes. Requirements, as every
developer knows, are subject to change. How change is managed is a key differen­
tiating factor between successful software projects and those that atrophy due to scope
creep. Developers can react in many ways to requirement changes, with two opposing
viewpoints highlighting the continuum that lies between.

First, developers can choose a rigid viewpoint. In this approach, from the develop-
ment process down to class design, the project is as inflexible as if it were implemented
50 years ago by using punch cards. Waterfall methodologies are conspicuous culprits
in ensuring that software cannot change freely. Their determination that the phases of
analysis, design, implementation, and testing be distinct and one-way make it difficult—
or at least expensive—for customers to change requirements after implementation has
begun. The code, then, does not need to be built for change: the process all but forbids
alterations.

The second approach, Agile methodology, is not just an alternative to such rigid
methodologies, but a reaction to them. The aim of Agile processes is to embrace change
as a necessary part of the contract between client and developer. If customers want to
change something in the product that they are paying for, the temporal and financial
cost should be correlated to the size of the change, not the phase of the process that is
currently in progress. Unlike physical engineering, software engineering works with a
malleable tool: source code. The bricks and mortar that form a house are literally fused
together as construction progresses. The expense involved in changing the design of
a house is necessarily linked to the completion of the building phase. If the project
has not been started—if it is still just in blueprints—change is relatively cheap. If the
windows are in, the electricity wired up, and the plumbing fitted, moving the upstairs
bathroom down next to the kitchen could be prohibitively expensive. With code, mov-
ing features around and reworking the navigation of a user interface should not be as

xv

From the Library of Ida Schander


significant. Unfortunately, this is not always the case. The temporal cost alone often
prohibits such changes. This, I find, is largely a result of a lack of adaptability in code.

This book demonstrates the second approach and explains, with real-world exam-
ples, the practicalities of implementing adaptive code.

Who should read this book


This book is intended to bridge a gap between theory and practice. The reader for
whom this book is written is an experienced programmer who seeks more practical
examples of design patterns, SOLID principles, unit testing and refactoring, and more.

Capable intermediate programmers who want to plug the gaps in their knowledge
or have doubts and questions about how some of the industry’s best practices fit
together will benefit most from this book, especially because the day-to-day reality
of programming rarely matches simple examples or theory. Much of SOLID is now
understood, but the intricacies of the open/closed principle (covered in Chapter 6)
and Liskov substitution (covered in Chapter 7) are not fully comprehended. Even
experienced programmers sometimes do not fully realize the benefits provided by
dependency injection (covered in Chapter 9). Similarly, the flexibility—adaptability—
that interfaces (covered in Chapter 3) lend to code is often overlooked.

This book can also help the more junior developer learn, from the ground up, which
aspects of common patterns and practices are benevolent and which are, in the long
term, malevolent. The code samples that I see from prospective employees have a lot
in common. The general theme is that the candidate is almost there with respect to
many skills but just needs a slight push in the right direction to become a significantly
better programmer. Specifically, the Entourage anti-pattern (covered in Chapter 2) and
the Service Locator anti-pattern (covered in Chapter 9) are very prevalent in sample
code. Practical alternatives, and their rationales, are provided in this book.

Assumptions
Ideally, you should have some practical experience of programming in a language that
is syntactically similar to C#, such as Java or C++. You should also have a strong founda-
tion in core procedural programming concepts such as conditional branching, loops,
and expressions. You should also have some experience of object-oriented program-
ming using classes, and at least a passing familiarity with interfaces.

xvi Introduction

From the Library of Ida Schander


This book might not be for you if…
This book might not be for you if you are just starting out on a journey to learn how to
program. This book covers advanced topics that assume a thorough understanding of
fundamental programming concepts.

Organization of this book


This book is made up of three parts, each of which builds on the last. That said, the
book can also be read out of order. Each chapter covers a self-contained subject in
detail, with cross references included where appropriate.

Part I: An Agile foundation


This part lays the foundation for building software in an adaptive way. It covers the
high-level Agile process known as Scrum, which requires code to be adaptive to change.
The chapters in this part focus on details around interfaces, design patterns, refactoring,
and unit testing.

■■ Chapter 1: Introduction to Scrum This chapter sets the scene for the book
by introducing Scrum, which is an Agile project management methodology. The
chapter gives an in-depth overview of the artifacts, roles, metrics, and phases
of a Scrum project. Finally, it shows how developers should organize themselves
and their code when operating in an Agile environment.

■■ Chapter 2: Dependencies and layering This chapter explores dependencies


and architectural layering. Code can only be adaptive if the solution’s structure
allows it to be. The different types of dependencies are described: first-party,
third-party, and framework. The chapter describes how to manage and organize
dependencies, from anti-patterns (which should be avoided) to patterns (which
should be embraced). It also introduces advanced topics such as aspect-oriented
programming and asymmetric layering, providing further depth.

■■ Chapter 3: Interfaces and design patterns Interfaces are, by now, ubiquitous


in modern .NET development. However, they are often misapplied, misunder-
stood, and misappropriated. This chapter shows some of the more common and
practically useful design patterns, exploring how versatile an interface can be.
Leading the reader beyond the simple extraction of an interface, the chapter

Introduction xvii

From the Library of Ida Schander


shows how interfaces can be elaborated in many different ways to solve a
problem. Mixins, duck-typing, and interface fluency further underscore the
versatility of this key weapon in the programmer’s arsenal.

■■ Chapter 4: Unit testing and refactoring Two practices that are becoming
prerequisite skills are unit testing and refactoring. The two are closely related
and work in unison to produce adaptive code. Without the safety net of unit
tests, refactoring is prone to error; without refactoring, code becomes unwieldy,
rigid, and hard to comprehend. This chapter takes an example of unit testing
from humble beginnings and expands it to use more advanced—but practical
—patterns and practices such as fluent assertions, test-driven development,
and mocking. For refactoring, the chapter provides examples of real-world
refactors that improve the readability and maintainability of the source code.

Part II: Writing SOLID code


This part builds on the foundation laid in Part I. Each chapter is devoted to examining
one principle of SOLID. The emphasis in these chapters is on practical examples for
implementing the principles, rather than solely on the theory of why. By placing each
example in a real-world context, the chapters in this part of the book clearly demon-
strate the utility of SOLID.

■■ Chapter 5: The single responsibility principle This chapter shows how to


implement the single responsibility principle in practice by using the Decorator
and Adapter patterns. The outcome of applying the principle is an increase in
the number of classes and a decrease in the size of those classes. The chapter
shows that, in contrast with monolithic classes that provide extensive features,
these smaller classes are more directed and focused on solving only a small part
of a larger problem. It is in their aggregation that these classes then become
more than the sum of their parts.

■■ Chapter 6: The open/closed principle The open/closed principle (OCP) is


simply stated, but it can have a significant impact on code. It is responsible for
ensuring that code that follows SOLID principles is only appended to and never
edited. This chapter also discusses the concept of predicted variation in relation
to OCP and explores how it can help developers identify extension points for
further adaptability.

■■ Chapter 7: The Liskov substitution principle This chapter shows the posi-
tive effects that result from applying the Liskov substitution principle on code,
particularly the fact that the guidelines help enforce the open/closed principle
and prevent the unintended consequences of change. Contracts—through

xviii Introduction

From the Library of Ida Schander


preconditions, postconditions, and data invariants—are covered by using the
Code Contracts tooling. The chapter also describes subtyping guidelines such
as covariance, contravariance, and invariance, along with the negative impact
of breaking these rules.

■■ Chapter 8: Interface segregation Not only should classes be smaller than


they commonly are, this chapter shows that interfaces are, similarly, often too
big. Interface segregation is a simple practice that is often overlooked; this
chapter shows the benefits of limiting interfaces to the smallest size possible,
along with the benefits of working with smaller interfaces. It also explores the
different reasons that might motivate the segregation of interfaces, such as
­client need and architectural need.

■■ Chapter 9: Dependency injection This chapter contains the cohesive glue


that holds together the rest of the features in the book. Without dependency
injection (DI), there is a lot that would not be possible—it is really that impor-
tant. This chapter contains an introduction to DI and a comparison of the differ-
ent methods of implementing it. The chapter includes discussions on managing
object lifetimes, working with Inversion of Control containers, avoiding common
anti-patterns relating to service location, and identifying composition roots and
resolution roots.

Part III: Adaptive sample


This part uses a sample application as a way of tying together the rest of the book.
Although there is a lot of code in these chapters, there is ample accompanying explana-
tion. Because this book is about working in an Agile environment, the chapters map to
Scrum sprints, and all work is the result of backlog items and client change requests.

■■ Chapter 10: Adaptive sample: Introduction This first chapter describes


the application that is to be developed: an online chat application developed
in ASP.NET MVC 5. A brief design is provided as a guideline for the planned
architecture, in addition to an explanation of the features on the backlog.

■■ Chapter 11: Adaptive sample: Sprint 1 Using a test-driven development


(TDD) approach, the first features of the application are developed, including
viewing and creating chat rooms and messages.

■■ Chapter 12: Adaptive sample: Sprint 2 The client, inevitably, makes some
changes to the requirements of the application, and the team accommodates
those changes through adaptive code.

Introduction xix

From the Library of Ida Schander


Other documents randomly have
different content
The young doctor came back and said, "Why, Dr. Tucker, it is almost
enough to make anyone ill just to go into these homes and see how
the people live. There are so many dark rooms and so little sunlight,
and the houses are very dirty. In almost every home someone is
sick." Dr. Tucker remembered how the multitudes came to Jesus and
were healed, and so he thought one of the best ways to give more
of the Bible to the people was to help those who were sick.
He had stereopticon pictures made which showed how tuberculosis
might be prevented. Then he went to the United States Ambassador
and to the mayor of Rio and to the president of the Board of Health
and to other great men who could help him and told them he was
going to give a lecture and wanted them to come and sit on the
platform. He sent cards out all over the city telling how many people
had tuberculosis and what they should do to be cured and inviting
people to his meeting.
Those who came were so much interested in the pictures, that the
city officials arranged for him to show them to the children in the
public schools. Then they had him talk to the people who gathered
in the public squares of the city. The government gave him money to
fight tuberculosis, and he started a hospital where sick people
without money could be treated and where they could hear and read
about Jesus the Great Physician.
Next he started a school for poor children. The children wanted to
come to school, and Dr. Tucker was very happy until he saw how
strangely they behaved.
"What can be the matter with them?" he asked. "They sit with their
hands folded. They don't want to study or even to play. Their eyes
are dull."
He asked the children questions and visited their homes to find out
why they did not want to study or to jump about and play.
"No wonder my school children sit with their hands folded," he said
when he came back. "They are half starved. Some of them have
nothing but a cup of coffee and a pickle to eat all day."
He remembered how Jesus had fed those who were hungry, so
every day he provided a lunch of whole wheat mush with milk and
sugar. Soon the hollow cheeks of the children began to get round
and rosy, their eyes began to shine, and they wanted to run and
jump and play.
"I wish we could feed all the hungry children in Rio," said Dr. Tucker
one day. He knew he could never get them all in his little school, but
he thought of another plan—he started a cooking school to teach
the mothers to cook good meals at home. He told the gas company
about his plan, and they gave him the stoves he needed. The
mothers came with their children, and while the children learned
reading and writing and arithmetic, the mothers learned how to
prepare food that was better for children than coffee and pickles. Dr.
Tucker had found another way to give the Bible to Brazil.
One day he said, "The Bible tells us to clothe the naked, but how
can we ever get clothes enough for all of the poor people of Brazil!"
Presently he walked into the office of a sewing machine company
and told the manager about his plan to clothe the naked.
"That would be fine!" the manager said. "Of course the only way to
clothe all the poor people is to teach them how to make their own
clothes."
He sent sewing machines to Dr. Tucker's school, and soon the
mothers were learning to sew. Dr. Tucker had found still another way
to give the Bible to Brazil.
Now his school children were well and happy. Their cheeks were
round and rosy, for they had a lunch at school and their mothers
gave them good food at home. Their clothes were neat and clean,
their eyes were bright and shining, and they were ready to study
and play. But where should they play? There was no trouble about a
place to study. They could study at school or at home, but when
they wanted to play there was no place at all. Rio is one of the most
beautiful cities in the world, and many of the people are very
wealthy and live in beautiful homes, but Dr. Tucker's poor little
children in the slums lived in houses that were built close together
right on the street.
There was a very beautiful park, with lovely green grass, but the
superintendent of parks was very proud of his green grass and had a
fence of iron rails around it with a sign, "Keep off the grass"
wherever a child could get in.
Every time Dr. Tucker saw that park, his eyes looked like the eyes of
his school children when they were hungry. But one day as he went
through the park, his eyes began to twinkle. He clapped his hands
and said to himself, "I'll do it!" At once he walked up boldly to the
mayor of Rio and the superintendent of parks.
"The children have no place to play," he said. "Why don't you open
up a part of the city park for a public playground?"
The mayor and the superintendent of parks were so shocked they
could scarcely say a word. They were so proud of their beautiful
park, they had never let people even walk on the grass; and now
this bold man actually dared to propose that they should put swings
and teeter boards and tennis courts right where the grass was most
beautiful!
But they could not forget what he said about happy children being
worth more than beautiful grass, and one day they drove to Dr.
Tucker's door in a fine automobile and invited him to ride with them.
They did not ask him where he wanted to go, but drove straight to
the park.
"We have decided to do what you ask and let you make your
playground on one condition," announced the mayor.
"Good!" said Dr. Tucker, "What's the condition?"
"That you get all the equipment for a first-class playground,"
answered the superintendent of parks.
Dr. Tucker was thinking very fast. "Equipment for a first-class
playground" meant swings and bars and teeter boards and tennis
nets and footballs and ever so many other things boys and girls love
in a playground. With the same twinkle that was in his eyes when he
looked at the park and said, "I'll do it," he said now, "All right, I'll
take you up."
He did not have a single cent in his pocket to buy all these things
and he did not know where he was going to get so much money, but
he said to himself:
"I'll look around a bit and see what I can see."
The first thing he saw was some men tearing up an old street-car
track. He went to the manager of the street-car company. "What are
you going to do with those old rails?" he asked. "May I have them?"
"Yes, I guess so," answered the manager.
Dr. Tucker said "Thank you" very politely and then added, "I'll have
to have them shaped a little differently and a few holes bored in
them. Would you mind doing this in your shop?"
The manager said he would do that, too. When Dr. Tucker said
"Thank you" very politely again and turned to go, the manager
asked: "What in the world do you want those old rails for?"
"For swing supports and all sorts of equipment for the playground."
He told the manager about his ride with the mayor and the
superintendent of parks and all about the things he was going to
make for the playground and athletic fields out of those lovely old
rails.
"Nonsense, man!" said the manager. "Those old rails aren't good
enough. Why you ought to have the best stuff money can buy for
Brazil's first public playground."
"Of course we ought," said Dr. Tucker, "but since we don't have the
money to buy them with, I propose to see what we can make."
"What would you buy if you did have the money?" asked the
manager. "Think it over and let me know."
Dr. Tucker went home and got a catalog of a New York store. A few
days later he went into the manager's office with the catalog in his
hand. The manager was so busy he scarcely had time to look up.
"Are you too busy to look at the things we need for the playground?"
asked Dr. Tucker.
"Yes, I am," replied the manager. "You just take that catalog and
mark what you need, and when I go to New York perhaps I can get
it for you."
Dr. Tucker's eyes twinkled twice that time. He felt as if his fairy
godmother had shown him a wonderful palace and told him to help
himself. He sat down and marked in that catalog the things he knew
the boys and girls of Rio would have marked if they had held his
pencil.
The manager took the catalog to New York with him and bought
every single article that had a mark before it. He paid for them with
dollars—seven hundred and forty of them—out of his own pocket.

Courtesy World's Sunday School Association


A Playground in Rio de Janeiro
On the grounds of an old private park the
children of the city now swing and slide and bat
and jump.
When the swings and bars and outfits came and were set up in the
park, the opening day was announced. The people came in crowds
from all over the city. The band played, and the flag of Brazil was
raised. The mayor made a speech, and the children cheered, and
then they scampered off to swing and slide and bat and jump; and
the first public playground of Brazil was open.
That evening Dr. Tucker walked down the street. He thought of his
million Bibles, and he thought of his school and his playground which
put the love of God into visible form.
"The Bible is coming into Brazil," he said to himself. "Not only into
the pulpits and into bookcases, but its spirit of love and service is
coming into the parks and schools and the streets and, best of all,
into the hearts of the people." And his own heart was glad.
III
THE STORY OF POIT

In the interior of South America, with the rivers Parana and Paraguay
to the east, with Argentine to the south, and Bolivia to the west,
there is a vast, low country called the Gran Chaco, about as large as
the state of Texas and inhabited by Indians. The country is flat and
there are grass-lands, swamps, and forests of palm trees. There are
many different animals with which the children of the North are not
familiar but of which they may have seen pictures, among them the
tapir, the marsh deer, the otter, the peccary, and the armadillo. There
are some savage animals such as the jaguar, the puma, and a very
large wolf with a long mane.
There are also some of the queerest animals in the world, especially
the ant-eater, a bow-legged creature seven feet long from the tip of
his snout to the tip of his hairy tail. There is a queer little opossum
about the size of a mouse, with enormous black eyes, fan-like ears,
and a long tail, which runs about in the trees like a squirrel. Most
interesting of all is the lungfish which can live either in the water or
in the air. In the wet season he stays in the swamps and eats and
eats, and when the dry season comes and the swamps disappear, he
burrows in the ground and lives without eating anything, by using up
the fat he has stored.
There are many birds both large and small, from great ostriches
down to tiny hummingbirds, and there are insects of all kinds, ants
and crickets and mosquitoes and beetles and locusts, and there are
twenty-four different kinds of frogs, each with a different croak.
For many weeks no rain falls, and the Indians have a hard time to
get along; then when the rain comes they have more than they need
to eat, water-birds, fish, and, by-and-by, their harvests. They do not
mind having to tramp round in deep water, because wet weather
brings plenty.
Among the Indians in this strange country was a young man named
Poit. One morning in December Poit awoke with a frightened,
anxious heart. It was not because he was too warm, though in
December in Chaco the mornings are hot, nor because he had not
slept comfortably on his bed on the ground nor because he was
hungry; it was because he plotted a wicked deed. Today Poit
planned to do the most dreadful thing anyone can do, he was going
to kill his best friend, the missionary.
Though these Indians lived so uncomfortably, they did not want to
change their ways, and they killed everybody who came to explore
their country or to search for silver or to tell them of the love of God.
Even soldiers sent to conquer them by force failed because they
were so fierce and cunning.
The chief reason for their resistance and their cruelty was not
wickedness, but ignorance and dreadful fear. They were afraid of
spirits and afraid of witches and wizards. They were so afraid that
the souls of the dead might come and annoy them that whenever
anyone died they destroyed the village and went to another place to
live. This wasn't very difficult because their houses were made of
boughs stuck into the ground. They were especially afraid of people
unlike themselves, and this was the reason they killed foreigners.
In spite of their objections, a little mission had been established
among them. It was situated on the banks of the Paraguay River
and its influence did not extend very far inland, but it was a
beginning. The first missionary died as a result of his hard work, and
there arrived one day a new missionary, a tall, slender young man,
hardly more than a boy in years, whose name was Barbrooke Grubb.
Mr. Grubb was not satisfied to stay along the river where he could
see only a few of the Indians, he determined to travel to the interior
villages. He knew perfectly well that the undertaking was dangerous.
He had heard of the explorers and the missionaries whom the
Indians had murdered; he knew that a poor white man who had
strayed from his companions and had taken refuge with them had
been slain; he knew that if sickness broke out while he was staying
in a village, he would be held responsible and be killed. He knew
that if an Indian had a bad dream about him, he might kill him.
Nevertheless, he not only visited the interior of the country, but he
lived with the Indians for months at a time, staying in their villages,
eating their strange food, hunting and fishing with them, so that he
might learn all about their ways and help them. He went unarmed
and unprotected, saying that he was a messenger of peace.
He had many thrilling experiences, and some that were very funny.
Of course he did not know the language well at first and he mistook
the word "evil" for the word "good," and assured the people that he
was a friend of the "evil spirit."

Courtesy of Samuel Guy Inman


Girls of the Chaco Mission School
They are not having a picnic, but have just eaten
their noonday meal, and the kettle of maize is
nearly empty.
He had many amusing encounters with the witch-doctors. You would
not think from the picture of a Chaco witch-doctor that they could
frighten anybody, but these natives lived in deadly fear of them. Mr.
Grubb proved how foolish it was to have faith in them. When a
witch-doctor claimed to have a charm against bullets, Mr. Grubb
said:
"All right; you stand over there and I'll shoot at you, and you won't
mind a bit."
The witch-doctor wouldn't hear of this trial, and the Indians laughed
at him.
Once Mr. Grubb heard that a witch-doctor was taking needles out of
his patients' bodies, and he proved that the witch-doctor bought all
the needles from him and that the cure was a pretense.
Some of the Indians were very smart. There was one called Pinse-
apawa, who came into Mr. Grubb's tent one day just as Mr. Grubb
was taking some medicine. This medicine had an alcoholic smell
though it had a dreadfully bitter taste, so bitter that you could hardly
swallow it. Pinse-apawa smelled the odor of liquor.
"Ah!" he said. "You won't let us drink liquor, but when you are here
alone you take it yourself!"
"Have some," invited Mr. Grubb.
Poor Pinse-apawa took a big swallow and after that he knew the
difference between liquor and medicine.

Now Poit, who opened his eyes on a warm December morning


intending to murder Mr. Grubb was not a witch-doctor; he was a
clever, intelligent Indian, and when he was good, he was a great
help. We do not like to call him a bad Indian, even though he was to
do such a dreadful deed. Though he had had every chance under Mr.
Grubb's teaching to learn to be good, he had not met him until he
was a grown man, and then it is very hard to change your heart.
By this time Mr. Grubb had been in the Chaco for seven years, and
the work he had done was truly wonderful. At the mission station
there was a settlement where the people lived in permanent houses
instead of wandering from place to place. Strangers could go about
unarmed and in safety. The Indians had been taught to work, not
only at odd moments, but steadily. They had been taught to take
care of sheep and cattle and to raise vegetables.
They had learned to distrust the witch-doctors and to take
precautions against contagion. They had learned to respect the law
and to live at peace with their neighbors. They had built several
hundred miles of cart tracks. They had axes, knives, hoes, scissors,
and many other possessions which Mr. Grubb had had shipped from
England to help them to live more comfortably and to earn their
living more easily. Some could even read and write.
They had learned still more important lessons. Mr. Grubb had taught
them that it was unspeakably wicked to kill the poor little babies as
they had been doing, and equally wrong to bury alive sick people
whom they thought would soon die. He had taught them also that it
was wrong to drink liquor because it made them frantic and wicked.
Though they did not always do what was right, hundreds of them
knew what was right, and had begun to try to be good.
They knew also—and this was most important of all—about God and
Jesus, and, though none had openly become Christians, the seed of
Christianity had been planted in their hearts.
Now Poit had a special chance to learn what was right because he
was constantly in the company of Mr. Grubb who had brought about
this wonderful transformation. He was very bright and Mr. Grubb
depended upon him, and he seemed very faithful and Mr. Grubb
trusted him. He could hunt and set traps, and steal quietly up to the
ostriches and capture them, and find his way through the woods,
and make bows and arrows, and do other useful things.
When Mr. Grubb had been in the Chaco for seven years he went
home to England for a vacation, the first vacation he had had. Other
young men had come to help him, and the mission was so well
established that it would not suffer in his absence.
Before he went away, he planned carefully for his return. He
intended then to visit a distant tribe called the Toothli, to which Poit
belonged, and he had already built a bullock road in that direction.
He sent Poit to a distant settlement with seventeen head of cattle
and other goods and told him that he was to settle down there and
make friends with the people. He was not to sell the cattle to people
who would use them for food, but only to those who would raise
other cattle, because Mr. Grubb was very anxious for the natives to
learn to care for stock.
Poit was to tell the Toothli that the missionaries would come and live
with them if they would do certain things. They must give up making
beer, and they must not hold feasts which lasted more than three
days. They must work when they were called upon for the good of
the whole settlement, and they must help to build the cart track and
keep it clear. They must live at peace with their neighbors, and
above all they must cease at once the killing of little children.
Poit had done so well, that this important work was entrusted to him
and off he went with his cattle and his goods. He was very proud
and at first he obeyed Mr. Grubb's directions. But alas, his pride in
Mr. Grubb's confidence and his feeling of responsibility did not
continue. He forgot what he had learned; he convinced himself that
Mr. Grubb was gone for good; and he took possession of the
property which Mr. Grubb had given him. He began to sell the cattle
to people who used them for food, and he took the money for
himself.
When Mr. Grubb came back, Poit was terrified. He had not believed
Mr. Grubb's promise nor had he understood in the least how devoted
Mr. Grubb was to his work. Now the money had to be paid over, and
he had to give an account of the cattle, and he had spent a part of
the money, and the cattle had been eaten. In order to cover his
crime, he stole money from the missionaries. He was so clever that
they did not at first suspect that he was the thief. But he could not
bring the cattle back to life and soon he realized that discovery was
at hand; Mr. Grubb would learn that he had not been faithful.
Mr. Grubb prepared at once to fulfil his promise to visit the Toothli
people, and so little did he suspect Poit of wrong-doing that he
made him the leader of the six Indians whom he took with him.
It was so hot that the party traveled by night to avoid the sun. They
had a pretty comfortable track to walk on, but on both sides were
thickets of trees and vines in which the twenty-four kinds of frogs
croaked in twenty-four different notes, and everywhere were
mosquitoes which flew out hungrily when they heard human beings
approaching.
Suddenly Mr. Grubb looked round and saw that, of all his company,
only Poit was in sight. He sent him back at once to find out why the
others lingered. In a little while Poit reappeared and reported that
one of the bearers had a thorn in his foot, and his companions were
extracting it. They would all be along, he said, in a few minutes.
But the few minutes passed and the Indians did not come. Poit had
wickedly told them that Mr. Grubb did not need them and that they
might return toward the mission. He had dreamed that when his
disobedience was found out, Mr. Grubb had killed him, and he had
decided in terror that he must kill Mr. Grubb as soon as possible. He
meant to go on for a few days until they had reached the Toothli
country and then he would do the deed. He believed that the people
of his tribe would help him to hide his crime.
Mr. Grubb noticed that Poit seemed downcast, but he did not dream
what he had in his heart. The two went on alone, and still the other
Indians did not overtake them. Poit suggested that perhaps they had
gone home because they did not approve of the journey. Still Mr.
Grubb did not suspect his evil intention, and they traveled on,
arriving presently at the village which was Poit's home.
Here Mr. Grubb inquired about the cattle, but everybody was in
league with Poit and helped him conceal his theft, and still Mr. Grubb
was deceived. The people said that the cattle had merely strayed
away, and he gave orders that they be collected before his return.
For two days he and Poit journeyed toward the distant settlements,
and at last Poit decided that he could postpone the murder no
longer. His heart was depressed when he woke, because in his sleep
he had understood more clearly than when he was awake what a
fearful thing it was to kill a man who had shown such love for those
who would gladly have been his enemies.
As he moved about, his courage revived; he ceased to be downcast
and became cheerful. So cold-blooded was he that he sat beside Mr.
Grubb on the ground while he sharpened the long iron arrow with
which he intended to kill him.

Barbrooke Grubb
Unarmed and unprotected, he was a messenger
of peace to the Indians of Paraguay.
They were now traveling by day, and they set out at about half-past
six for their last journey together. The sun was already high and so
hot that it had dried the heavy dew. They had gone but a short
distance when Mr. Grubb saw that he had been led into a thicket. He
observed a strange look on Poit's face, and did not realize that he
had caught Poit's eye at the moment when he was trying to get into
a position from which he could shoot him.
A moment later he bent over, trying to break a path through the
undergrowth, and in that instant Poit lifted his bow and arrow. A
stinging blow under his shoulder blade, and Mr. Grubb understood in
a flash that this was not his friend but his enemy, and that he had
been shot, perhaps fatally.
When the deed was done, Poit came to himself. He shouted in
dismay and terror, "Ak kai! Ak kai!" and rushed away.
He had run only a short distance when he sat down to think. He
believed that he had either killed Mr. Grubb outright or that Mr.
Grubb would soon die from his wounds or that he would be slain by
a jaguar whose tracks they had crossed. He decided craftily that he
would set out straightway for the mission and say that he had seen
a jaguar about to leap, and that, shooting at the jaguar, he had
killed Mr. Grubb.
He had not gone very far when he met an Indian with paint marks
on his body, which showed that he was in mourning. Poit supposed
this meant that Mr. Grubb was dead—someone must have found Mr.
Grubb's body before the jaguar devoured it. He ran back into the
forest. By this time he was out of his mind with fear. For hundreds
and hundreds of years the Indians had killed foreigners without
thinking anything about it; but now there was a change. Here was
an Indian mourning for a foreigner! Poit was puzzled and frightened.
He did not yet know that all the Indians were crying out for
vengeance upon the man who had tried to murder their benefactor.
But what neither Poit nor the mourning Indian knew was that Mr.
Grubb was still alive. How he reached the mission was a miracle. He
was more dead than alive from the wound which pierced his lung,
and from exhaustion. Sometimes he staggered along leaning on two
Indians; sometimes he rode a horse on whose back he had to be
supported. Often his companions had to lay him down on the ground
lest he should die. He suffered from the heat by day and was
tortured by the mosquitoes by night. As though this were not
enough, one night a goat belonging to an Indian jumped on him by
accident!
But at last he reached the mission and had proper medical attention,
and all along the weary way the Indians saw his agony and
understood that he was suffering because he had come to help
them. They thought not only of him, but of the Master about whom
he had told them, and they believed that he had been saved by a
miracle.
Though Mr. Grubb still lived, the Indians decided that Poit must die,
and they searched for him until they captured him. He pleaded with
them desperately, reminding them that he was their relative whom
they had known all their lives and that Mr. Grubb was only a
stranger; but they would not listen.
When he heard that Poit was to die, Mr. Grubb tried to save him, but
in vain. He did, however, succeed in saving Poit's family whom the
Indians would have killed also. This forgiving spirit amazed and
touched them still more.
Now this story is sad and dreadful and there would not be any
reason for telling it if Poit's death were the end. But in a way, it was
only a beginning.
Mr. Grubb had to make two journeys for further medical attention,
one to Ascuncion, nearly four hundred miles away, and one to
Buenos Ayres, nine hundred miles away. It was December when Poit
attacked him; it was June before he was able to take up his work.
When he did so, the seed so strangely sown by poor Poit had
ripened. Two Indians who had been impressed by Mr. Grubb's
devotion and by his almost miraculous recovery asked to be
baptized. Thus the foundation of the Church in the Chaco was laid.
Mr. Grubb is still working, and the extent of his influence has greatly
increased. The Indians in the distant settlements no longer wait for
him to seek them out; they come to see for themselves what he has
done and to hear the story he has to tell. The government has
named him the "pacificator of the Indians."
Do you not suppose that sometimes as he thinks of his years in the
Chaco, he thinks with pity of poor Poit and hopes that his cry "Ak
kai! Ak kai!" showed repentance as well as fear of punishment?
IV
TREE-NOT-SHAKEN-BY-THE-WIND

Ten-year-old Fred Hope looked up at the men who looked down at


him. He was very happy because he had just taken the pencil and
paper which one of the men handed him, and written
Fred Hope $1.00
He lived on a farm near Flat Rock, Illinois, and many times he had
seen his father sign his name to a subscription paper when the
deacons had been collecting money for the church and had made up
his mind that some day he would sign his own name. At last he had
done so, and his eyes were shining.
"Now," said he, "I've got to find a way to make that dollar."
He took a hoe and some beans and went into the garden to begin to
earn his dollar. He planted the beans and watched eagerly to see
them grow. It was a bad year for beans in Illinois and there was no
crop. But he did not give up. From beans he turned to rats. The rats
had been eating his father's grain and Fred made a contract to rid
the place of rats at five cents apiece. It happened there were more
rats than beans in Flat Rock that year and no Indian chief ever
counted with more pride his scalps of white men than Fred the
notches which numbered the rats he had slain. Soon the dollar was
paid, and his father's grain was safe.
The next money Fred made was to pay his way to college. When he
had almost enough saved, his mother said:
"Father does not see how he can get along without you on the farm.
He has had a great deal of trouble and lost a lot of money."
"Of course I'll stay, and I'll find a way to go to college later on,"
answered Fred.
When he was twenty-four years old he went to Maryville College in
Tennessee. There he had to begin with the small boys in the
preparatory department.
"You might just as well give up," said some of his friends. "You are
so far behind you can never catch up."
But Fred only laughed. "I'll find a way. When I can't raise beans I
always catch rats."
He worked as hard at his lessons as he had on the farm, and played
as well as he worked. He was the best man on his football team, and
when he graduated he was president of his class.
While he was at school he thought he would like to be a missionary,
but he did not wish to be a preacher and he had never heard of a
missionary who was not a preacher. At last he settled it this way:
"If God wants me to be a missionary and there is any way I can be a
missionary without being a preacher then I'll be one."
A few years later as a steamer neared the west coast of Africa, Fred
Hope jumped from one of the berths. He called to his wife to dress
as fast as she could so they should not miss the first glimpse of the
shore.
He had found a way; he was going to Elat on the west coast of
Africa to take charge of the Frank James Industrial School. As he
stood on the deck in the gray light of the early morning, he seemed
to see John Ludwig Krapf and Robert Moffat and David Livingstone
and all the men and women who had found a way to give their lives
to Africa, and his heart was glad.
He could see two white dwelling houses surrounded by tall coconut-
palms and other tropical plants, beyond the dashing surf at the
Batanga landing. How anxious he was to reach them! The travelers
were lowered to the small boat in a "Mammy chair," a seat swung by
ropes from the deck of the steamer. Then the sturdy black men
pulled for the shore, their wet backs gleaming in the sunlight.
A boy who had come from Elat to meet them was waiting with two
bicycles. Mr. Hope had never been on a bicycle, so he practised
riding round and round, to the amusement of all the crowd. Then he
and Mrs. Hope started on their long journey of one hundred and ten
miles in the narrow path through the African jungle.
On either side of them giant trees reached upward for many, many
feet before spreading out branches to the sunlight above.
Underneath the trees there was no sunshine, only the gloom of
dense foliage. It made them feel as though they were in a great
cathedral,—the quiet, the great pillars of the trees, and the dim
light.
As they rode on through the villages and the bush, people crowded
round them curiously. The black men could not speak the white
man's words or make the white man understand their words. They
pointed to Mr. Hope's head.
"They want you to take off your hat so they can see your straight
hair," said the boy.
Mr. Hope took off his hat. They looked at his straight hair very
solemnly. Then they pointed to Mrs. Hope's head.
"They want to see the hair that is like long ropes," said the boy. Mrs.
Hope took off her hat.
They moved their hands to their heads and then far out until she
understood that they wanted her to take out the hairpins and stretch
her hair as far as it would reach "like long ropes."
They gazed with wonder at its length and softness. Then one of
them opened his mouth and pointed first to his teeth and then to Mr.
Hope's mouth. Soon every black man was doing the same thing.
"They want to see your brass teeth," the boy explained. Mr. Hope
opened his mouth, while the people who had never heard of a
dentist gazed with much respect at the gold fillings.
"How do the people all along the way know we are coming?" asked
Mr. Hope. "There are no telegraph wires or telephones."
"By the drums," answered the boy. "Every village has its drums.
They are hollowed out of logs so the ends make curious sounds that
speak to those who listen. When you pass through a village the men
who beat the drums call to the next village, 'Strange white man is
here.' All important men have drum names. Perhaps you will do
something so brave they will give you a drum name some day."
When they reached Elat, Mr. Hope began to find the work God had
provided for a man who was not a preacher. The missionaries who
had been in Africa said that the boys and men who went home after
being in the mission schools had nothing to do. There were no
stores for them to run, no factories or shops in which they could
work, and no one had ever taught them how to farm.

© Underwood and Underwood


Native African "Wireless Station"
Every village on the West Coast has its drum by
which messages are sent from village to village.
There were not even any decent houses. They had to live in little
huts made out of the bark of trees, with a dirt floor, no windows,
and only one little door, so low that they had almost to crawl in.
Their houses had only one room, and in that room all the family
cooked and ate and slept. The chickens stayed in a little room built
at the side of the house. There was no way for them to get in except
through the same door that led through the house. Often they
stopped to take a peck at the food the women were grinding
between heavy flat stones.
The houses were very dirty. The women had no time to keep their
houses clean; they had to dig and hoe the ground and harvest the
crops and look after their children and cook the meals.
Meanwhile the men sat round the huts and smoked and drank and
palavered. To "palaver" means to talk and talk and then talk some
more. Sometimes they went hunting and sometimes they fought
men of other tribes. If they had known how to work or if it had been
the custom for them to work, they would not have been so good-for-
nothing.
Mr. Hope decided that one of the best deeds one could do for Africa
would be to teach the men and boys how to work, to build decent
houses and churches and towns, to make furniture and clothes, and
to use the wonderful natural gifts God has given to Africa.
The Frank James Industrial School had been started to do all of
these things and half a dozen boys were there to welcome the new
superintendent. The school building was a little bark shack much like
a native hut. From an industrial school at Old Calabar Mr. Hope
secured a tailor and a carpenter. He found an old hand sewing
machine which someone had almost worn out in America and then
put into a missionary box for Africa. Then the boys were ready to
sew.
The first order they took was for clothes for a party of men who
came many miles carrying burdens. In the interior of Africa there are
no freight or express lines and everything is carried on the heads or
backs of men. These bearers had come one hundred and twenty-five
miles carrying sixty-five pounds each. They received one cent a mile
for their loads. When they got their money, Mr. Hope said, "it burned
their pockets, or would have burned them if they had had any
pockets." That was just what they wanted—some pockets like the
white men. They wore only pieces of bark cloth tied around their
waists.
They wanted to spend their money at once and asked how much
they could buy for $1.25. Mr. Hope told them that would not buy a
whole suit of clothes, so they decided that each of them would get a
coat, since a coat had more pockets than trousers. The boys in the
tailoring school took their measure for their first order for "clothes
made while you wait."
They waited for a whole week and then went home each wearing a
khaki coat and as happy as if he had a full outfit. Since that day the
tailoring class has never caught up with its orders. The men and
boys have made clothes for themselves, for the missionaries and
their wives and children, and for people in the country round about.
They have even made uniforms for army officials. They can do all
this work because now they have large, plank buildings and
machinery which includes fifteen sewing machines.
But tailoring would not keep everyone busy, and other things besides
clothes were needful, so Mr. Hope put some of the boys to work in a
carpentry class. Logs of beautiful wood were brought from the
wonderful forests. There were no great trucks in Elat, so a team of
fifteen or twenty men was made up to haul the logs to the saw mill
and from there they were taken to the carpenter shop.
At first all the lumber was sawed by hand, and it took two men all
day to saw out half a dozen planks. Then Mr. Hope wrote to America
for an engine. When the big engine landed at Batanga the people
were very much excited.
"Let us go with you to bring it to Elat," said several of the men.
"How will we be able to pull such a big engine that weighs so
much?" asked one.
"You are an ignorant man," answered another. "Do you not know the
strange thing that white men say of this engine?"
"What is it that they say?"
"They say that men need not pull this engine along the road, but
that if men will make fire in it and put water over the fire the engine
will walk by itself along the road."
When they reached Batanga they helped to put the water in the
boiler and make the fire and then they saw the engine "walk by
itself."
They had traveled about thirty-five miles along the wide, new road,
and Mr. Hope was thinking how wonderful it would be to have the
big engine at the saw mill, when there was a crash, and the bridge
over the muddy stream they were crossing went down. The engine
turned over and dropped twenty feet into the creek below.
Mr. Hope and his friend, who were riding on the engine, went down
with it and were thrown to one side. The black men thought they
were killed, for heavy timbers had fallen all around them, but they
soon crawled out alive and stood looking at their engine lying upside
down in the mud of the little creek.
The black men said the engine could never be raised from the creek.
Mr. Hope only smiled, and went to work. In a week the engine was
standing on the road ready to walk by itself again.
Then a message came from the governor saying the engine would
not be allowed to walk through his country. But even this did not
discourage Mr. Hope. He sent back to Elat for one hundred men.
They came and hitched themselves to the engine like horses and
pulled it all the long way to Elat, where from that time it sawed the
wood as fast as it was needed. It was a year from the time they
started until they pulled the engine into Elat.
At first the boys made very simple furniture, but soon they advanced
to dining-room extension tables, couches, davenports, and
bookcases. Morris chairs were their especial delight, and they have
invented ingenious folding-chairs.
Mr. Hope looked at some American wicker and willow furniture and
said, "We ought to beat that in Africa, because we have such
wonderful bush-rope in the jungles."

Courtesy Presbyterian Board of Foreign Missions


At the Frank James Industrial School, Elat, Africa
The boys gathered rattan vines, and Fred Hope
showed them how to make attractive bush-rope
furniture.
So the boys began to gather rattan vines of different sizes and make
it into bush-rope furniture which was so beautiful that when foreign
officers visited Africa and saw it, they insisted on taking samples
home with them.
Next the boys turned their attention to building houses. They
practised on houses for themselves; then they built houses for the
missionaries. They decorated Mr. Hope's house with beautiful
mahogany panels made from the trees that grew right at their door.
When, after a while, the government needed large warehouses the
boys from Elat were able to build them.
Their greatest triumph was the Elat church. This is not a little chapel
as one might expect in a mission; it is a church that seats four
thousand people. Not only did they build the church, but they made
all the furniture for it, and the many thousands of mats of dried
grass with which the roof was covered. Next they went around the
country building other Christian churches as they were needed.
They learned to make small articles as well as large. From the tusks
of the elephants, which were not in cages at the Zoo, but at home in
the forests all about, they made ivory chessmen.
Of course, Mr. Hope cannot keep forever the many boys and men
who come to the school. Most of them must go back to their own
homes. He wanted them to know how to farm when they went back,
so he laid out a little farm for them to practise on at the schools, and
here they learn the best methods of planting and cultivating. They
have tried to find new plants which might grow in Africa. Our own
American Agricultural Bureau became interested in exchanging
plants and seeds, and before long we will see African vegetables in
America and American vegetables in Africa.
Some boys are taught to become blacksmiths and in their shop they
do everything from putting a new blade into a pocket-knife to
rebuilding an automobile.
"An automobile!" you say. "Where did they find it?" It happened in a
curious fashion. Elat was in German territory and when the Great
War began and the Germans were driven away, they did not wish to
leave behind anything that would be of help to the French army, so
they piled up all their bicycles, motor cycles, automobiles, and trucks
and wrecked them with sledges and blew them up with dynamite. To
be sure that nothing was left they set fire to the wreck. The French
officers came along and looked at the pile of scrap iron and said,
"Junk! Nothing worth taking with us," and gave it to the mission.
When Fred Hope saw it, his eyes shone just as if they had taken him
into a big supply store and said, "Help yourself." Some people might
have shrugged their shoulders in despair, but Mr. Hope and his
assistant, Mr. Cozzens, set the boys at the school to work on the
junk heap, and out of it they made an automobile. This model is not
to be bought in the American market, but it has a number of good
points all its own. Then they made an auto-truck. What was left was
made into a steam engine which runs the shaft that in turn runs a
planer, a boring machine, a shingle mill, a grinder, and a large lathe.
During the war there was no oil to be had for the machinery, but Mr.
Hope did not stop all the wheels and cable to America that he would
have to close the school.
"See all these beans growing around us," he said to his boys. "They
are almost like the castor beans we have in America, and Americans
make oil out of the castor bean. Bring me a jack from the carpenter
shop." The boys ran to get the jack. "Now, turn it upside down and
make a press out of it."
They mashed the beans until a thick oil ran out. Then Mr. Hope
bought peanuts, not ten cents worth in a paper sack from the corner
store, but tons from the farms where they grew. The boys mashed
them until barrelfuls of oil were stored away. It was a better grade
and much cheaper than the oil they bought from Europe. Today two
hydraulic presses make the manufacture of oil easy.
"What shall we do now?" asked a boy one day. "There are no more
of the American brooms."
"Why not make brooms here in our own school?" said Mr. Hope.
They planted broom-corn seed and it grew so well that now broom-
making is one of the trades taught at Elat.
During the war there was no soap to be had. Some people said,
"How dreadful!" but Mr. Hope said, "What good luck! We shall have
to find a way to make our own soap."
He sent to America for lye, and the school has added soap-making
to its other work.
One day the boys asked what they should do with the shavings in
the carpenter shop.
"Burn them," said Mr. Hope. "Burn all of them."
The foolish boys set fire to them on the dirt floor of the shop. They
were piled up so high that the roof mats caught fire and in a few
moments there was nothing left of the carpentry shop but a pile of
ashes and a few blackened tools.
But almost before the ashes were cold, Mr. Hope started the
remorseful boys to building another shop, and in less than a week
they were back at work.
Many of the young men who came to the school were married, and
Mr. Hope decided that he would build a town where each man who
attended school could live in his own home. His town now has
houses on each side of the street and more than one hundred
families live there. In the afternoons, Mrs. Hope has classes for the
girls and women. She teaches them to cook and to sew, to read and
to write, and to take care of their children.
After the boys and men and their wives have finished their training
in the schools, they go back to their own villages. Often they build
themselves a home. The chief is sure to be interested in a man who
has a house better than his own, so the mission boys become men
of importance.
Hundreds of boys have been turned away from the school because
they could not be accommodated. Only the strongest Christian boys
are chosen. These boys come from all parts of the mission and are
recommended for admission by the missionaries who know them.
Fred Hope
His steadfastness and perseverance won for him
from the Africans the name, "Tree-Not-Shaken-
by-the-Wind."
Frequently the boys themselves become missionaries. They build
churches and tell the people the wonderful story of the "Tribe of
God" to which they belong. Many of them start schools. None of
them sit around their huts all day and smoke and drink and beat
their wives and quarrel, as their fathers and grandfathers used to do.
While they learn their trades, they become better Christians, not
only because they listen to the preaching on Sunday, but because
they watch Mr. and Mrs. Hope and the other missionaries and see
how they live.
Fred Hope said he would be a missionary if he could be one without
being a preacher, yet he preaches every day. Sometimes he ventures
to stand up in church or among the people who crowd the doors of
the mission, and tell them the story of the Son of God who gave
Himself for them, but most of his preaching is his every-day living.
He has won his "drum name." He began to win it when he paid his
pledge for $1.00 by catching rats when his bean crop failed, and
always since then he has found some way to do the things that he
undertakes no matter how hard they are or how many difficulties he
meets.
If you were in an African village which Mr. Hope was about to visit,
you would not be handed a telegram stating "Fred Hope has
arrived," but instead, you would hear the drums beat the call, "'Tree-
Not-Shaken-by-the-Wind' is here."
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like