Full Chapter Designing Hexagonal Architecture With Java 2Nd Edition PDF

You might also like

You are on page 1of 53

Designing Hexagonal Architecture with

Java 2nd Edition --


Visit to download the full and correct content document:
https://textbookfull.com/product/designing-hexagonal-architecture-with-java-2nd-editio
n/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Get Your Hands Dirty on Clean Architecture Build clean


applications with code examples in Java 2nd Edition Tom
Hombergs

https://textbookfull.com/product/get-your-hands-dirty-on-clean-
architecture-build-clean-applications-with-code-examples-in-
java-2nd-edition-tom-hombergs/

Cloud Native Java Designing Resilient Systems with


Spring Boot Spring Cloud and Cloud Foundry 1st Edition
Long

https://textbookfull.com/product/cloud-native-java-designing-
resilient-systems-with-spring-boot-spring-cloud-and-cloud-
foundry-1st-edition-long/

Lean UX Designing Great Products with Agile Teams 2nd


Edition Jeff Gothelf

https://textbookfull.com/product/lean-ux-designing-great-
products-with-agile-teams-2nd-edition-jeff-gothelf/

Computer Graphics Programming in OpenGL with Java 2nd


Edition V. Scott Gordon

https://textbookfull.com/product/computer-graphics-programming-
in-opengl-with-java-2nd-edition-v-scott-gordon/
RESTful Java Web Services A pragmatic guide to
designing and building RESTful APIs using Java 3rd
Edition Balachandar

https://textbookfull.com/product/restful-java-web-services-a-
pragmatic-guide-to-designing-and-building-restful-apis-using-
java-3rd-edition-balachandar/

Computer Organization and Architecture Designing for


Performance 10th Edition William Stallings

https://textbookfull.com/product/computer-organization-and-
architecture-designing-for-performance-10th-edition-william-
stallings/

Guide to Web Development with Java - Understanding


Website Creation 2nd Edition Tim Downey

https://textbookfull.com/product/guide-to-web-development-with-
java-understanding-website-creation-2nd-edition-tim-downey/

Designing with Data Rochelle King

https://textbookfull.com/product/designing-with-data-rochelle-
king/

Designing Type 2nd Edition Karen Cheng

https://textbookfull.com/product/designing-type-2nd-edition-
karen-cheng/
Designing Hexagonal Architecture with
Java
Copyright © 2023 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing or its dealers and distributors, will be held liable for any damages
caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Kunal Sawant

Publishing Product Manager: Akash Sharma

Senior Editor: Nisha Cleetus

Technical Editor: Shruti Thingalaya

Copy Editor: Safis Editing

Proofreader: Safis Editing

Project Manager: Deeksha Thakkar


Indexer: Rekha Nair

Production Designer: Nilesh Mohite

Business Development Executive: Kriti Sharma

Developer Relations Marketing Executives: Rayyan Khan and Sonia Chauhan

First published: January 2022

Second edition: September 2023

Production reference: 1220923

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK

ISBN 978-1-83763-511-5

www.packtpub.com
To the memory of my mother, Rosimar Pinheiro, who instilled in me the desire
to learn. To my father, Davi, for teaching me the value of persistence. To my
brother, Bruno Pinheiro, for his influence on my character and career. To my
wife, Eloise, for being my loving partner throughout our joint life journey. To
my son, Davi, who brings immense joy and happiness to my life.
– Davi Vieira

Contributors

About the author


Davi Vieira is a software craftsman with a vested interest in the challenges faced
by large enterprises in software design, development, and architecture. He has
more than 10 years of experience in constructing and maintaining complex, long-
lasting, and mission-critical systems using object-oriented languages. He values
the good lessons and the software development tradition left by others who came
before him. Inspired by this software tradition, he develops and evolves his ideas.
I want to especially thank my wife, Eloise, and my son, Davi, for the
motivation to keep moving forward. I also wish to thank Fagner Silva, a
person I admire and who is responsible for introducing me to hexagonal
architecture. This book would not have been possible if I had not met him. I
want to thank Pooja Yadav for coming to me with the idea to write this
second edition. And thanks to the fantastic Packt team, with special mention
to Deeksha Thakkar and Nisha Cleetus, for being my partners and supporting
me throughout this long journey.

About the reviewers


Vikranth Etikyala is a senior staff software engineer at Fintech SoFi and a
speaker who talks about cloud and storage technologies. He is currently leading a
team of engineers building SoFi Bank’s infrastructure using modern cloud
technologies. Previously, he was an early member of Amazon Simple Storage
Service (S3), a planet-scale storage system, where he was involved in building
foundational storage infrastructure and leading efforts to scale S3 during its
exponential growth. He spearheaded features such as List v2 , Transfer
Acceleration, and Intelligent Archival, which now handle millions of transactions
per second, moving petabytes of data. He also holds a master’s degree in
computer science from Northeastern University.

Muhammad Edwin is a senior consultant at Red Hat’s APAC Global Professional


Services specializing in cloud-native application and integration architectures. He
loves technology and getting his hands dirty exploring new tech, frameworks, and
patterns. He lives in the suburbs of Jakarta, Indonesia, and, when not involved in
tech stuff, spends most of his time playing classic Japanese RPGs on his gaming
rig.
Table of Contents

Preface
Part 1: Architecture Fundamentals

Why Hexagonal Architecture?


Technical requirements
Reviewing software architecture
Making decisions
The invisible things
Technical debt
Vicious cycle
It’s not for everyone
Monolithic or distributed
Understanding hexagonal architecture
Domain hexagon
Application hexagon
Use cases
Output ports
Framework hexagon
Advantages of the hexagonal approach
Summary
Questions
Further reading
Answers

Wrapping Business Rules inside Domain Hexagon


Technical requirements
Modeling a problem domain with entities
The purity of domain entities
Relevant entities
Using UUIDs to define identity
Enhancing descriptiveness with value objects
Using value objects to compose entities
Assuring consistency with aggregates
Modeling an aggregate
Working with domain services
Using policy and specification to deal with
business rules
Creating specifications
Creating policies
Defining business rules as POJOs
Summary
Questions
Further reading
Answers
3

Handling Behavior with Ports and Use Cases

Technical requirements
Expressing software behavior with use cases
How to create a use case
Implementing use cases with input ports
Using output ports to deal with external data
It’s not only about repositories
Where to use output ports
Automating behavior with the Application
hexagon
Summary
Questions
Further reading
Answers

Creating Adapters to Interact with the Outside World


Technical requirements
Understanding adapters
Using input adapters to allow driving operations
Creating input adapters
Using output adapters to speak with different
data sources
Creating output adapters
Summary
Questions
Answers
Further reading

Exploring the Nature of Driving and Driven Operations

Technical requirements
Reaching the hexagonal application with driving
operations
Integrating web applications with the hexagonal
system
Creating the Add Network page
Creating the Get Router page
Running test agents
Calling the hexagonal system from other
applications
Handling external resources with driven
operations
Data persistence
Messaging and events
Mock servers
Summary
Questions
Answers
Part 2: Using Hexagons to Create a Solid Foundation

Building the Domain Hexagon


Technical requirements
Bootstrapping the Domain hexagon
Understanding the problem domain
Defining value objects
Defining entities and specifications
The Equipment and Router abstract entities
The core router entity and its specifications
Edge router entity and its specifications
Switch entity and its specifications
Defining domain services
Router service
Switch service
Network service
Testing the Domain hexagon
Summary
Questions
Answers
7

Building the Application Hexagon

Technical requirements
Bootstrapping the Application hexagon
Defining use cases
Creating written descriptions for router
management use cases
Defining the use case interface for router
management
Creating written descriptions for switch
management use cases
Defining the use case interface for switch
management
Creating written descriptions for network
management use cases
Defining the use case interface for network
management
Implementing use cases with input ports
Testing the Application hexagon
Summary
Questions
Answers

8
Building the Framework Hexagon

Technical requirements
Bootstrapping the Framework hexagon
Implementing output adapters
The router management output adapter
The switch management output adapter
Implementing the input adapters
The router management input adapter
The switch management input adapter
The network management input adapter
Testing the Framework hexagon
Summary
Questions
Answers

Applying Dependency Inversion with Java Modules


Technical requirements
Introducing the JPMS
Inverting dependencies on a hexagonal
application
Providing services with use cases and input
ports
Providing services with output ports and output
adapters
Making the input adapters dependent on
abstractions
Using the Java platform’s ServiceLoader class to
retrieve JPMS provider implementations
Initializing RouterManagementGenericAdapter
Initializing SwitchManagementGenericAdapter
Initializing NetworkManagementGenericAdapter
Summary
Questions
Answers
Further reading
Part 3: Becoming Cloud-Native

10

Adding Quarkus to a Modularized Hexagonal


Application
Technical requirements
Revisiting the JVM
Speeding up runtime performance with JIT
compilation
Improving startup time with AOT compilation
Introducing Quarkus
Creating REST endpoints with JAX-RS
Employing dependency injection with Quarkus
DI
Validating objects
Configuring a data source and using Hibernate
ORM
Adding Quarkus to a modularized hexagonal
application
Summary
Questions
Answers

11
Leveraging CDI Beans to Manage Ports and Use Cases

Technical requirements
Learning about Quarkus DI
Working with beans
Transforming ports, use cases, and adapters into
CDI beans
Implementing CDI for router management
objects
Implementing CDI for switch management
objects
Implementing CDI for network management
classes and interfaces
Testing use cases with Quarkus and Cucumber
Summary
Questions
Answers

12

Using RESTEasy Reactive to Implement Input


Adapters

Technical requirements
Exploring the approaches to handling server’s
requests
Imperative
Reactive
Implementing input adapters with RESTEasy
Reactive
Implementing the Reactive input adapter for
router management
Implementing the Reactive input adapter for
switch management
Implementing the Reactive input adapter for
network management
Adding OpenAPI and Swagger UI
Testing Reactive input adapters
Summary
Questions
Answers

13

Persisting Data with Output Adapters and Hibernate


Reactive

Technical requirements
Introducing Hibernate Reactive and Panache
Hibernate Reactive features
Panache features
Enabling reactive behavior on output adapters
Configuring reactive data sources
Configuring entities
Implementing reactive repository classes
Implementing reactive output adapters
Reactive router management of the MySQL
output adapter
Reactive switch management of the MySQL
output adapter
Testing the reactive output adapters
Summary
Questions
Answers

14

Setting Up Dockerfile and Kubernetes Objects for


Cloud Deployment
Technical requirements
Preparing the Docker image
Creating a Docker image with an uber .jar
artifact
Creating a Docker image with a native
executable
Creating Kubernetes objects
Reviewing Kubernetes' main objects
Configuring Kubernetes objects for the
hexagonal system
Deploying on minikube
Summary
Questions
Answers
Part 4: Hexagonal Architecture and Beyond

15

Comparing Hexagonal Architecture with Layered


Architecture
Technical requirements
Reviewing the layered architecture
Creating an application using the layered
architecture
Implementing the data layer
Implementing the service layer
Implementing the API layer
Testing the layered application
Refactoring a layered architecture application
into a hexagonal one
Implementing the Domain hexagon
Implementing the Application hexagon
Implementing the Framework hexagon
Testing the hexagonal application
Assessing the benefits and disadvantages of
hexagonal and layered architectures
Summary
Questions
Answers

16

Using SOLID Principles with Hexagonal Architecture


Technical requirements
Understanding SOLID principles
Single Responsibility Principle (SRP)
Open-Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)
Applying SOLID on a hexagonal architecture
system
Applying the SRP
Applying the OCP
Applying the LSP
Applying the ISP
Applying the DIP
Exploring other design patterns
Singleton
Builder
Abstract factory
Summary
Questions
Answers

17

Good Design Practices for Your Hexagonal Application


Technical requirements
Using Domain-Driven Design to shape the
Domain hexagon
Understanding the business we are in
Promoting collaboration to increase knowledge
Applying DDD techniques to build the Domain
hexagon
Implementing bounded contexts and subdomains
in a hexagonal system
The need for creating ports and use cases
Dealing with multiple adapter categories
Conclusion – the hexagonal journey
Summary
Questions
Answers

Index

Other Books You May Enjoy


Preface
Sometimes, solving problems and expressing our ideas through code is
challenging. What looks like an obvious solution in our minds may look
unnecessarily complex in the minds of others. But that’s alright if we are open to
new ideas and perspectives because we set our minds to learning unexpected
things when we have a persistent attitude and a willingness to embrace everything
that comes.

I was not expecting it when I was first introduced to hexagonal architecture.

I remember working in a company where most of the software was developed by


consultants. Those folks would come, deliver their code, and leave. Although my
team and I tried to establish specific standards to ensure consistency in the
applications we were responsible for, the harsh reality was that we needed more
knowledge to maintain our applications properly. Given the number of systems and
the different approaches and architectures employed to build them, it took a lot of
work to maintain and add new features to such systems. That’s when a teammate
told me about the hexagonal architecture and how it could help us tackle hard-to-
maintain software problems.

At that time, there weren’t many books covering the hexagonal architecture. Most
of the resources were scattered on the internet through video courses and articles
explaining how someone implemented hexagonal architecture. The lack of
resources was a considerable obstacle, but using an architecture that could
improve software maintainability was very attractive to me. So, I kept researching
and experimenting in my own job with the ideas, which would ultimately lead to
me writing the first edition of this book.

I am fortunate to have had the opportunity to write the first, and now the second,
edition of a book dealing with such a fascinating topic as hexagonal architecture.
The second edition has allowed me to employ hexagonal architecture ideas with
more recent versions of Java and Quarkus. This edition preserves the
fundamentals from the previous one while exploring modern Java’s new and cool
features. Also, this edition explores how hexagonal architecture can be used with
the acclaimed SOLID principles and how it relates to the widely used layered
architecture.

Concepts such as ports, adapters, and use cases are combined with Domain-
Driven Design (DDD) elements such as entities and value objects to provide an
in-depth guide explaining how to assemble those concepts to untangle the exciting
puzzle of designing highly change-tolerable applications with hexagonal
architecture. Considering the contemporary cloud-native practices that dictate
most enterprise development today, we deep dive into Quarkus to learn how to
blend hexagonal architecture ideas with cloud-native development, which enables
us to create enterprise-grade hexagonal applications ready to be deployed in any
major cloud provider.

So, I encourage you to have a persistent attitude and a willingness to embrace


everything that comes and embark with me on this fascinating journey to explore
hexagonal architecture.
Who this book is for
This book is suited for Java architects and Java developers at senior and
intermediate levels. The reader is expected to have previous knowledge of object-
oriented language principles and be acquainted with the Java programming
language. Previous professional Java experience is also recommended, as this
book is concerned with problems that usually happen in enterprise software
development projects using Java.
What this book covers
Chapter 1, Why Hexagonal Architecture?, starts by discussing how software that is
not well organized and lacks sound architectural principles may work fine but will
present a high risk of developing technical debt. As new features are added, the
software tends to become more complex to maintain because there is no common
ground to guide the addition or change of features. Based on this problem, this
chapter explains why hexagonal architecture helps tackle technical debt by
establishing an approach where business code is decoupled from technology code,
allowing the former to evolve without dependency on the latter.

Chapter 2, Wrapping Business Rules inside the Domain Hexagon, follows a


domain-driven approach and describes what domain entities are, what role they
play within hexagonal architecture, and how they wrap business rules and data in
simple Java POJOs. It explains why domain entities are the most important part of
code and why they should not depend on anything other than other domain
entities. Finally, it explains how business rules inside a domain entity can be
implemented using the Specification design pattern.

Chapter 3, Handling Behavior with Ports and Uses Cases, covers what use cases
are, explaining that they are used to define software intent with interfaces
describing things the software can do. Then, it explains what input ports are and
the classes that implement use case interfaces, and specifies in concrete ways
how the software intent should be accomplished. It talks about output ports and
their role in abstractly defining the behavior of operations that need to get data
from outside the software. Finally, this chapter explains how use cases and ports
are grouped in what’s called the Application hexagon.

Chapter 4, Creating Adapters to Interact with the Outside World, shows how
adapters allow the software to integrate with different technologies. It explains
that the same port can have multiple adapters. Input adapters, bound to input
ports, enable the application to expose its functionalities through different
communication protocols, such as REST, gRPC, or WebSocket. Output adapters,
bound to output ports, allow the application to communicate with varying data
sources, whether it be databases or even message queues or other applications.
Finally, the chapter shows how all adapters are grouped in the Framework
hexagon.

Chapter 5, Exploring the Nature of Driving and Driven Operations, explains that
driver operations drive the software behavior by starting one of its exposed
functions. It details the driver operations life cycle, showing how a request is
captured on the Framework hexagon through an input adapter and then handed
down to an input port on the Application hexagon until it reaches the entities from
the Domain hexagon. It shows that a use case starts driven operations from the
Application hexagon when the software needs to get data from outside, going
from an output port to an output adapter to fulfill the use case needs.

Chapter 6, Building the Domain Hexagon, shows how to start developing a telco’s
network and topology inventory application by first creating the Domain hexagon
as a Java module. Then, this chapter shows how business rules and data are
mapped to domain entities’ classes and methods. The business rules are arranged
in different algorithms with the aim of the Specification design pattern. Finally, it
shows how to unit test the Domain hexagon.

Chapter 7, Building the Application Hexagon, starts by adding the Application


hexagon as the second Java module on the application. It then explains how to
create the use case interface that describes the software’s operations to manage
the network and topology inventory. It shows how to implement the use case with
an input port, giving a detailed description of how the code should be arranged. It
details the creation of an output port interface and its role in obtaining data from
external sources. Finally, it explains how to test the Application hexagon.

Chapter 8, Building the Framework Hexagon, starts by adding the Framework


hexagon as the third Java module on the application. Then, it teaches you how to
create an input adapter and how it will carry out its operations through an input
port. After that, an output adapter is created through the implementation of an
output port. The output adapter will show how data can be fetched from external
Another random document with
no related content on Scribd:
Fig. 37

It is said that the Indians boiled these berries, and then thought
them very good to eat.
If we were lost in the woods, and obliged to live upon the plants
about us, I dare say we should eat, and perhaps enjoy eating, many
things which now seem quite impossible; but until this happens I
advise you not to experiment with strange leaves and roots and
berries. Every little while one reads of the death of some child as the
result of eating a poisonous plant.

Fig. 38

The next picture (Fig. 38) shows you the fruit of Solomon’s seal.
These dark-blue berries hang from beneath the leafy stem, just as
the little flowers hung their yellow heads last May.
Next come the speckled red berries of the false Solomon’s seal
(Fig. 39), a big cousin of the smaller plant. As you see, this bears its
fruit quite differently, all in a cluster at the upper part of the stem.
These two plants seem to be great chums, constantly growing side
by side.
We have been so busy and so happy that the morning has flown,
and now we must be finding our way home to dinner; for, unlike the
birds, we are not satisfied to dine on berries alone.

Fig. 39

At almost every step we long to stop and look at some new plant
in fruit; for, now that we have learned how to look for them, berries of
different sorts seem thick on every side.

Fig. 40
Fig. 41

Low at our feet are the red ones of the wintergreen (Fig. 40).
On taller plants grow the odd white ones, with blackish spots, of
the white baneberry (Fig. 41), or the red ones of the red baneberry.
Still higher glisten the dark, glass-like clusters of the spikenard.

Fig. 42

Along the lane are glowing barberries (Fig. 42) and thorns bright
with their “haws” (for the fruit of the thorn is called a “haw”). These
look something like little apples.
Here, too, is the black alder, studded with its red, waxy beads. But
we must hurry on, not stopping by the way. And you can be sure that
those birds we hear chirruping above us are glad enough to be left to
finish their dinner in peace.
WHY SEEDS TRAVEL

A T last I think we all understand that by the red of the apple, the
purple of the plum, and the different colors worn by the berries
we find in the woods, these plants are inviting us, and the birds also,
to eat their fruit, and so release from prison their little seeds.
But what would happen, do you suppose, if no one should accept
this invitation? What would become of their seeds if these pears and
apples and berries were not eaten by boys and girls and birds?
Most of this question you can answer for yourselves.
If you leave the apple on the tree, after a time it falls off upon the
ground; and unless picked up, there it lies till it decays. In the
orchard every fall you see apples decaying on the ground. In a little
while the fleshy part disappears, and the little seeds are thus let out
of prison without help.
But many plants are not satisfied to leave their seeds so near
home. Why is this, do you suppose?
Well, this is quite a long story.
All plants of the same kind need just the same sort of food. If too
many apple trees grow together, they soon use up all the apple-tree
food in the neighborhood.
So if a seed is to grow into a strong, hearty, well-fed plant, it ought
to begin life in some place not already full of plants in search of just
the food that it needs for itself.
If a plant or tree makes its fruit so good to eat that some boy or girl
or bird is likely to pick it, the chances are that it will be carried at
least a short distance before its seeds are dropped upon the ground.
Once in a while a plant is rewarded for its pains by having its
young carried thousands of miles.
Think how far from its home the peach has traveled. As I told you
before, it comes to us from Persia.
Now, if the Persian peach tree had not made its fruit very juicy and
delicious, it is not likely that any one would have taken the trouble to
bring its seeds way over here to us.
But this peach being what it is, one of the most delicious of fruits,
the tree was rewarded for its pains by having its children taken
where they were petted, and made much of, and had things all their
own way; for no other peach trees were on hand to do their best to
crowd them out.
Then think of the little partridge berry. The fleshy part of this the
birds eat and digest. But the little seeds pass unharmed from the
bird’s stomach to the earth, sometimes many miles from the woods
where they were born.
What is true of the peach and of the partridge berry is true of many
other fruits.
Without the help of man or bird or beast, these little seeds could at
last get out of their seed cases; but without such help, often they
could not get the start in life they need.
So it would seem as if a fruit’s bright color and delicious flavor
were saying to us not only, “Come and eat us and set our seeds
free,” but also, “and carry us far away, so that we may have a fair
chance in the world.”
SOME LITTLE TRAMPS

Fig. 43

W HEN I came home from that walk in the woods the other day, it
took me some time to rid my clothes of many odd-looking little
things, such as you see in the picture above (Fig. 43).
This round burr (Fig. 44) was one of the worst of my hangers-on.
You know it quite well. It is the fruit of the burdock. Can some child
tell me why I call this prickly burr a fruit?

Fig. 44

Now let us look carefully at this seed case or fruit of the burdock.
Instead of being smooth to the touch, like some other fruits we
know, such as the apple and the pear, it is covered with stiff hooks.
By these hooks it fastened itself so firmly to my clothes, that it was
difficult to pull it off without making a tear.
Why does the burdock put its seeds into such a prickly case?
Please stop reading for a moment and try to answer this question.
Cudgel well your brains for the use of such a prickly seed case as
that of the burdock plant.
Now I am hoping that one of you children will be able to think out
some such answer as this:—
“Of course, the burdock plant doesn’t want its seeds to fall on the
piece of ground that has been used up already by other burdocks,
any more than the partridge vine wishes to drop its seeds in the
same little hollow where other partridge vines have eaten all the
good food. As this burdock plant cannot make its seed case so bright
and pretty, and good to eat, that the birds will carry it off, it must
manage in some other way to send its seeds on their travels. And
this is what it does: it covers the seed case with little hooks. When
the seeds inside are quite ripe, this case breaks off very easily. So
when the children come hunting berries, it hooks itself to their
clothes, or else it catches in the hair of their dogs, or takes hold of
the wool of grazing sheep, and gets carried quite a way before it is
picked or rubbed off. When that happens, it is far enough from its old
home to set up for itself.”
I should indeed be pleased if one of you children could give me
some such answer as that.
So you see this prickly seed case does just as much for its little
charges as the juicy apple and velvety peach do for theirs.
And the same thing is true of all those other hooked, or barbed, or
prickly little objects that I picked off my clothes the other day, and
that cling to you when you take a walk in the fall woods.
They are all fruits. They are the ripe seed cases of the different
plants.
But they are dull-looking, and often quite vexing, instead of being
pleasant to the sight and taste and touch.
This makes no difference, however, in their having things pretty
much their own way. We do not in the least want to carry abroad
these little torments, scattering far and wide their seeds, so that
another year there will be more burrs and barbs and bristles than
ever, to tear our clothes and worry our dogs; but they force us to do
them this service, whether we will or no, and never stop to say “By
your leave.”
At every turn they are waiting for us. Where we climb the fence,
and cross the fields, and break through the woods, we can almost
fancy that we hear them whispering together, “Here they come! Now
is our chance!”
They remind us of those lazy tramps that lie along the railway,
getting on the trucks of passing trains, and stealing rides across the
country.
These ugly hooked fruits have one great advantage over the pretty
ones that are good to eat. They do not have to wait our pleasure. But
when we are most busy and hurried, without a moment to loiter in
the apple orchard or among the berry bushes, then, quite as well as,
if not better than, during our leisure moments, they lay hold upon us
with their tiny claws, and cling closely till we set to work to get rid of
them. When we pick them off and fling them to the ground, we are
doing just what they most wish.

Fig.
45

In this picture (Fig. 45) you see the seed case of the tick trefoil.
This plant belongs to the Pea family; and its fruit is really a pod,
something like that of the garden pea. But when this pod of the tick
trefoil is ripe, it splits into five little pieces. Each piece is a separate
seed case. This is covered with hooked hairs, by means of which it
fastens itself to our clothing and to the hair of animals, just as the
burr of the burdock did. These little seed cases go by the name of
“ticks.”
Fig. 46

Here is the fruit of the stick-tight (Fig. 46). You see its two teeth
that are so well fitted to weave themselves into either cloth or hair.
Fig. 47 shows you a strange and terrible fruit of this same class. It
grows on an African plant, and may fasten itself so firmly into the hair
of animals, that the attempt to get it out is almost hopeless.
Sometimes an unfortunate lion will kill himself in his efforts to wrench
this tormenting seed case from his skin. In his struggles he gets it
into his mouth, and so dies.

Fig. 47

I am glad to say we have nothing so terrifying as this among our


hooked fruits.
Even if at times you are tempted to lose your patience with such
impertinent little tramps as they are, I think you can hardly help
admiring the clever way in which they manage to get a free ride.
SEED SAILBOATS

O N your way to school these fall days, often you notice certain
white, silky things floating lazily through the air. Sometimes you
catch one of these little objects, and blow it away again with a
message to a friend. Or perhaps you wish upon it. At least, this is
what I did as a child. Life in those days was full of these mysterious
“wishes.” A white horse, a hay cart, the first star, a wandering thistle
down,—each promised the possible granting of one’s most secret
wish.
That the thistle down comes from the thistle plant, you know. But
not all the silky things that look like fairy sailboats are thistle down,
for many plants beside the thistle let loose these tiny air ships.
Have you ever wondered where they come from, what they are
doing? Or do they seem to you so lazy, so drifting, so aimless, that
you doubt if they are going anywhere in particular, or have really
anything to do?
But by this time you have learned that plants have better reasons
for their actions than you had dreamed before you began to pay
them some attention. You have discovered that they dress their
flowers in gay colors so that the bees may be tempted to visit them
and powder them with golden dust. You have learned that they make
their fruits juicy and delicious so that boys and girls and birds may be
persuaded to carry off their seeds; and the better you know them,
the more certain you feel that they manage their affairs with much
common sense, that they are not likely to take time and trouble for
nothing.

Fig. 48

So let us look closely at some of these air ships, and try to guess
their errand.
I hope that some time ago you were told to get together as many
different kinds as you could find, and to bring them here this
morning.
Fig. 49

In this picture you see some of the air ships of the milkweed (Fig.
49).
The lower part of Fig. 48 is a seedbox of the milkweed. To this are
fastened the silky threads which make the sail that carries the seed
through the air with the least wind, just as the canvas sail carries the
boat across the water.
Can you think of some other plants that send abroad seed
sailboats?
Perhaps some of you remember the beautiful pink or purple
flowers which grew last summer in tall spikes along the road and up
the mountain side. These were borne upon a plant called sometimes
fireweed and again willow herb (Fig. 50). The first name was given to
it because it grows freely in places that have been laid waste by fire.
The latter one it owes to its leaves, which look somewhat like those
of the willow.
Fig. 50

Fig. 51

By the end of August most of these beautiful blossoms had


disappeared, leaving in their place the fruit. This fruit of the fireweed
or willow herb is a long pod such as you see in the picture (Fig. 51).
This pod is packed full of seeds, to each one of which is fastened a
silky sail. Finally all these pods split open, letting out their little air
ships (Fig. 52), and giving a beautiful, feathery look to the great
patches in which they are found.

Fig. 52
Fig. 53

Fig. 54

Another plant which launches air ships is the clematis. In August


its pretty white blossoms clamber over the stone wall, and twist
about the bushes and trees, making the lanes very lovely. In the fall
this climber is almost as pretty as in summer, for its fruit clusters
(Fig. 53) are made of such long-tailed seeds as you see in Fig. 54.
When these open, and float away with the first light wind, you can
see how well their little sails are fitted to catch the breeze.

Fig. 55

Fig. 56

In October and November nearly every roadside is lined with


clusters such as you see in the next picture, except that the picture
cannot give their soft, velvety look. These are the fruit clusters of the
golden-rod (Fig. 55), made up of quantities of silky-tailed seeds such
as you see above (Fig. 56).
And this is the fruit cluster of the aster (Fig. 57). Each little puffball
is composed of many aster seeds (Fig. 58).

Fig. 57

Fig. 58

The pasture thistle is almost as beautiful in fruit as in flower. It


swells up into a great silvery cushion, which finally vanishes in a
cloud of floating thistle down.
And here is the fruit cluster of the dandelion (Fig. 59), and also a
single seed sailboat (Fig. 60).
Hundreds of other plants attach these little sails to their seeds.
You can hardly walk a step in the fall along the country roads without
meeting these masses of feathery fruit made up of just such seeds.
So now we come back to our questions, “Where are they going?
What are they doing?”
Fig. 59

Fig. 60

And as you have learned why the apple tree and the partridge vine
pack their seeds in pretty cases, and why the burdock and the stick-
tight cover theirs with hooks and bristles, you ought to answer these
questions very easily. You found that those plants wished to send
their little seeds abroad, so that they might get a better foothold in
some piece of earth that was not used already by plants hungry for
the very food that they most needed.
This is just what the thistle and milkweed and dandelion and aster
want for their seeds; and this is why they fasten them to little sails,
and send them far away on a voyage of discovery.
WINGED SEEDS

Fig. 61

M ANY of the trees also send their seeds on air voyages, in the
hope of finding some piece of land that will give them a chance
to grow into new, strong trees.
The seeds of the willow (Fig. 62) have silky white sails such as we
have found already in the plants of the milkweed and willow herb;
and the cottonwood tree is so called because its tufted seeds remind
one of the famous cotton seeds from which we get our cotton thread
(Fig. 63).

Fig. 62

There are other trees which use wings instead of sails when they
send their seeds flying through the air.
Fig. 63

Here you have the winged fruits of the maple (Fig. 64). In summer
you see these winged fruits hanging in clusters from the trees; and
later in the year they are thickly scattered along the village street and
in the city squares.

Fig. 64

You can understand how easily the maple seeds inside these
cases would be carried upon the breeze by their wings.
Each seed of the elm tree is winged nearly all the way round. The
picture (Fig. 65) shows you a cluster of these as they look upon the
tree.
Fig. 65

Fig. 66

Here is a bunch of the long-winged seeds of the ash (Fig. 66).


Next comes a fruit cluster from the hop hornbeam (Fig. 67), and
above is a single fruit (Fig. 68).

You might also like