0% found this document useful (0 votes)
14 views

Buy ebook Learning JavaScript Design Patterns Addy Osmani cheap price

The document provides information about various ebooks available for download, focusing on design patterns in JavaScript and Python. It includes links to specific titles such as 'Learning JavaScript Design Patterns' by Addy Osmani and 'Pro JavaScript Design Patterns' by Ross Harmes. The content emphasizes the importance of design patterns in software development and offers resources for developers looking to enhance their coding skills.

Uploaded by

buleysiddh60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Buy ebook Learning JavaScript Design Patterns Addy Osmani cheap price

The document provides information about various ebooks available for download, focusing on design patterns in JavaScript and Python. It includes links to specific titles such as 'Learning JavaScript Design Patterns' by Addy Osmani and 'Pro JavaScript Design Patterns' by Ross Harmes. The content emphasizes the importance of design patterns in software development and offers resources for developers looking to enhance their coding skills.

Uploaded by

buleysiddh60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Download the Full Version of the Ebook with Added Features ebookname.

com

Learning JavaScript Design Patterns Addy Osmani

https://ebookname.com/product/learning-javascript-design-
patterns-addy-osmani/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Learning JavaScript Design Patterns A JavaScript and React


Developer s Guide 2nd Edition Adnan Osmani

https://ebookname.com/product/learning-javascript-design-patterns-a-
javascript-and-react-developer-s-guide-2nd-edition-adnan-osmani/

ebookname.com

Pro Javascript Design Patterns 1st Edition Ross Harmes

https://ebookname.com/product/pro-javascript-design-patterns-1st-
edition-ross-harmes/

ebookname.com

Learning Python Design Patterns 2nd Edition Chetan


Giridhar

https://ebookname.com/product/learning-python-design-patterns-2nd-
edition-chetan-giridhar/

ebookname.com

The Body Politic in Roman Political Thought 1st Edition


Julia Mebane

https://ebookname.com/product/the-body-politic-in-roman-political-
thought-1st-edition-julia-mebane/

ebookname.com
Cambridge English for Nursing Pre intermediate Student s
Book with Audio CD Cambridge English For Series 1st
Edition Allum
https://ebookname.com/product/cambridge-english-for-nursing-pre-
intermediate-student-s-book-with-audio-cd-cambridge-english-for-
series-1st-edition-allum/
ebookname.com

Smart Buildings Systems for Architects Owners and Builders


James M Sinopoli

https://ebookname.com/product/smart-buildings-systems-for-architects-
owners-and-builders-james-m-sinopoli/

ebookname.com

Dietary Modulation of Cell Signaling Pathways 1st Edition


Zigang Dong

https://ebookname.com/product/dietary-modulation-of-cell-signaling-
pathways-1st-edition-zigang-dong/

ebookname.com

Global Politics 9th Edition James Ray

https://ebookname.com/product/global-politics-9th-edition-james-ray/

ebookname.com

Materials Degradation and Its Control by Surface


Engineering 3rd Edition Andrew W Batchelor

https://ebookname.com/product/materials-degradation-and-its-control-
by-surface-engineering-3rd-edition-andrew-w-batchelor/

ebookname.com
WHO Guidelines for the Management of Postpartum
Haemorrhage and Retained Placenta 1st Edition World Health
Organization
https://ebookname.com/product/who-guidelines-for-the-management-of-
postpartum-haemorrhage-and-retained-placenta-1st-edition-world-health-
organization/
ebookname.com
Learning JavaScript Design
Patterns

Addy Osmani

Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo


Learning JavaScript Design Patterns
by Addy Osmani

Copyright © 2012 Addy Osmani. All rights reserved.

Revision History for the :


2012-05-01 Early release revision 1
See http://oreilly.com/catalog/errata.csp?isbn=9781449331818 for release details.

ISBN: 978-1-449-33181-8
1335906805
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2. What is a Pattern? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
We already use patterns everyday 4

3. 'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three . . . . . . . . . . . . . . . . . . . . . . 7

4. The Structure Of A Design Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5. Writing Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

6. Anti-Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

7. Categories Of Design Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15


Creational Design Patterns 15
Structural Design Patterns 16
Behavioral Design Patterns 16

8. Design Pattern Categorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17


A brief note on classes 17

9. JavaScript Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


The Creational Pattern 22
The Constructor Pattern 23
Basic Constructors 23
Constructors With Prototypes 24
The Singleton Pattern 24
The Module Pattern 27

iii
Modules 27
Object Literals 27
The Module Pattern 29
The Revealing Module Pattern 36
The Observer Pattern 37
Advantages 38
Disadvantages 39
Implementations 39
The Mediator Pattern 49
Advantages & Disadvantages 50
Mediator Vs. Observer 51
Mediator Vs. Facade 51
The Prototype Pattern 52
The Command Pattern 54
The Facade Pattern 56
The Factory Pattern 58
When To Use The Factory Pattern 59
When Not To Use The Factory Pattern 59
The Mixin Pattern 60
The Decorator Pattern 61
Subclassing 61
Decorators 63
Example 1: Basic decoration of existing object constructors with new
functionality 63
Example 2: Simply decorate objects with multiple decorators 64
Pseudo-classical decorators 65
Interfaces 65
This variation of decorators and abstract decorators 66
Implementing decorators with jQuery 69
Pros and cons of the pattern 70

10. Flyweight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Flyweight and the data layer 72
Converting code to use the Flyweight pattern 72
A Basic Factory 74
Managing the extrinsic states 74
The Flyweight pattern and the DOM 76
Example 1: Centralized event handling 76
Example 2: Using the Flyweight for Performance Gains 77

11. MV* Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


MVC 79
Smalltalk-80 MVC 79

iv | Table of Contents
MVC For JavaScript Developers 80
Models 81
Views 82
Controllers 85
Controllers in another library (Spine.js) vs Backbone.js 86
What does MVC give us? 87
Delving deeper 88
Summary 88
MVP 88
Models, Views & Presenters 89
MVP or MVC? 90
MVC, MVP and Backbone.js 90
MVVM 92
History 92
Model 93
View 94
ViewModel 96
Recap: The View and the ViewModel 98
Recap: The ViewModel and the Model 98
Pros and Cons 98
Advantages 98
Disadvantages 98
MVVM With Looser Data-Bindings 99
MVC Vs. MVP Vs. MVVM 103
Backbone.js Vs. KnockoutJS 103
Namespacing Patterns 104
What is namespacing? 104
Advanced namespacing patterns 105
Automating nested namespacing 105
Dependency declaration pattern 107
Deep object extension 108
Namespacing Fundamentals 110
1.Single global variables 111
2. Prefix namespacing 111
3. Object literal notation 112
4. Nested namespacing 114
5. Immediately-invoked Function Expressions (IIFE)s 115
6. Namespace injection 117

12. Design Patterns in jQuery Core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


Module Pattern 121
Lazy Initialization 122
The Composite Pattern 123

Table of Contents | v
The Adapter Pattern 123
The Facade Pattern 124
The Observer Pattern 125
The Iterator Pattern 126
The Strategy Pattern 127
The Proxy Pattern 127
The Builder Pattern 128
The Prototype Pattern 128

13. Modern Modular JavaScript Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131


The Importance Of Decoupling Your Application 131
A Note On Script Loaders 132
AMD 132
A Format For Writing Modular JavaScript In The Browser 132
Getting Started With Modules 133
AMD Modules With Dojo 137
AMD Module Design Patterns (Dojo) 138
AMD Modules With jQuery 139
AMD Conclusions 141
CommonJS 141
A Module Format Optimized For The Server 141
Getting Started 141
AMD && CommonJS Competing, But Equally Valid Standards 144
Basic AMD Hybrid Format (John Hann) 145
AMD/CommonJS Universal Module Definition (Variation 2, UMDjs) 145
Extensible UMD Plugins With (Variation by myself and Thomas Davis). 146
ES Harmony 148
Modules Of The Future 148
Modules With Imports And Exports 148
Modules Loaded From Remote Sources 149
Module Loader API 150
CommonJS-like Modules For The Server 150
Classes With Constructors, Getters & Setters 150
Conclusions And Further Reading A Review 152

14. Bonus: jQuery Plugin Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


Patterns 154
Note 154
A Lightweight Start 155
Further Reading 156
“Complete” Widget Factory 157
Further Reading 159
Namespacing And Nested Namespacing 159

vi | Table of Contents
Further Reading 161
Custom Events For Pub/Sub (With The Widget factory) 161
Further Reading 162
Prototypal Inheritance With The DOM-To-Object Bridge Pattern 162
Further Reading 164
jQuery UI Widget Factory Bridge 164
Further Reading 166
jQuery Mobile Widgets With The Widget factory 167
RequireJS And The jQuery UI Widget Factory 169
Further Reading 172
Globally And Per-Call Overridable Options (Best Options Pattern) 172
Further Reading 174
A Highly Configurable And Mutable Plugin 174
Further Reading 176
UMD: AMD And CommonJS-Compatible Modules For Plugins 176
Further Reading 179
What Makes A Good Plugin Beyond Patterns? 179

15. Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

16. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

Table of Contents | vii


Preface

Design patterns are reusable solutions to commonly occurring problems in software


design. They are both exciting and a fascinating topic to explore in any programming
language.
One reason for this is that they help us build upon the combined experience of many
developers that came before us and ensure we structure our code in an optimized way,
meeting the needs of problems we're attempting to solve.
Design patterns also provide us a common vocabulary to describe solutions. This can
be significantly simpler than describing syntax and semantics when we're attempting
to convey a way of structuring a solution in code form to others.
In this book we will explore applying both classical and modern design patterns to the
JavaScript programming language.

Target Audience
This book is targeted at professional developers wishing to improve their knowledge
of design patterns and how they can be applied to the JavaScript programming lan-
guage.
Some of the concepts covered (closures, prototypal inheritance) will assume a level of
basic prior knowledge and understanding. If you find yourself needing to read further
about these topics, a list of suggested titles is provided for convenience.
If you would like to learn how to write beautiful, structured and organized code, I
believe this is the book for you.

Acknowledgments
I will always be grateful for the talented technical reviewers who helped review and
improve this book, including those from the community at large. The knowledge and
enthusiasm they brought to the project was simply amazing. The official technical re-

ix
viewers tweets and blogs are also a regular source of both ideas and inspiration and I
wholeheartedly recommend checking them out.
• Luke Smith (http://lucassmith.name, @ls_n)
• Nicholas Zakas (http://nczonline.net, @slicknet)
• Andrée Hansson (http://andreehansson.se, @peolanha)
• Alex Sexton (http://alexsexton.com, @slexaxton)
I would also like to thank Rebecca Murphey (http://rebeccamurphey.com, @rmur-
phey) for providing the inspiration to write this book and more importantly, continue
to make it both available on GitHub and via O'Reilly.
Finally, I would like to thank my wonderful wife Ellie, for all of her support while I was
putting together this publication.

Credits
Whilst some of the patterns covered in this book were implemented based on personal
experience, many of them have been previously identified by the JavaScript community.
This work is as such the production of the combined experience of a number of devel-
opers. Similar to Stoyan Stefanov's logical approach to preventing interruption of the
narrative with credits (in JavaScript Patterns), I have listed credits and suggested reading
for any content covered in the references section.
If any articles or links have been missed in the list of references, please accept my
heartfelt apologies. If you contact me I'll be sure to update them to include you on the
list.

Reading
Whilst this book is targeted at both beginners and intermediate developers, a basic
understanding of JavaScript fundamentals is assumed. Should you wish to learn more
about the language, I am happy to recommend the following titles:
• JavaScript: The Definitive Guide by David Flanagan
• Eloquent JavaScript by Marijn Haverbeke
• JavaScript Patterns by Stoyan Stefanov
• Writing Maintainable JavaScript by Nicholas Zakas
• JavaScript: The Good Parts by Douglas Crockford

x | Preface
CHAPTER 1
Introduction

One of the most important aspects of writing maintainable code is being able to notice
the recurring themes in that code and optimize them. This is an area where knowledge
of design patterns can prove invaluable.
In the first part of this book, we will explore the history and importance of design
patterns which can really be applied to any programming language. If you're already
sold on or are familiar with this history, feel free to skip to the chapter 'What is a
Pattern?' to continue reading.
Design patterns can be traced back to the early work of a civil engineer named Chris-
topher Alexander. He would often write publications about his experience in solving
design issues and how they related to buildings and towns. One day, it occurred to
Alexander that when used time and time again, certain design constructs lead to a
desired optimal effect.
In collaboration with Sara Ishikawa and Murray Silverstein, Alexander produced a
pattern language that would help empower anyone wishing to design and build at any
scale. This was published back in 1977 in a paper titled 'A Pattern Language', which
was later released as a complete hardcover book.
Some 30 years ago, software engineers began to incorporate the principles Alexander
had written about into the first documentation about design patterns, which was to be
a guide for novice developers looking to improve their coding skills. It's important to
note that the concepts behind design patterns have actually been around in the pro-
gramming industry since its inception, albeit in a less formalized form.
One of the first and arguably most iconic formal works published on design patterns
in software engineering was a book in 1995 called Design Patterns: Elements Of Reusable
Object-Oriented Software. This was written by Erich Gamma,Richard Helm,Ralph
Johnson andJohn Vlissides - a group that became known as the Gang of Four (or GoF
for short).
The GoF's publication is considered quite instrumental to pushing the concept of de-
sign patterns further in our field as it describes a number of development techniques

1
and pitfalls as well as providing twenty-three core Object-Oriented design patterns
frequently used around the world today. We will be covering these patterns in more
detail in the section ‘Categories of Design Patterns’.
In this book, we will take a look at a number of popular JavaScript design patterns and
explore why certain patterns may be more suitable for your projects than others. Re-
member that patterns can be applied not just to vanilla JavaScript (i.e standard Java-
Script code), but also to abstracted libraries such as jQuery or dojo as well. Before we
begin, let’s look at the exact definition of a ‘pattern’ in software design.

2 | Chapter 1: Introduction
CHAPTER 2
What is a Pattern?

A pattern is a reusable solution that can be applied to commonly occurring problems


in software design - in our case - in writing JavaScript-powered applications. Another
way of looking at patterns are as templates for how you solve problems - ones which
can be used in quite a few different situations.
So, why is it important to understand patterns and be familiar with them?. Design
patterns have three main benefits:
1. Patterns are proven solutions: They provide solid approaches to solving issues
in software development using proven solutions that reflect the experience and
insights the developers that helped define and improve them bring to the pattern.
2. Patterns can be easily reused:A pattern usually reflects an out of the box solution
that can be adapted to suit your own needs. This feature makes them quite robust.
3. Patterns can be expressive:When you look at a pattern there’s generally a set
structure and ‘vocabulary’ to the solution presented that can help express rather
large solutions quite elegantly.
Patterns are not an exact solution. It’s important that we remember the role of a pattern
is merely to provide us with a solution scheme. Patterns don’t solve all design problems
nor do they replace good software designers, however, they do support them. Next
we’ll take a look at some of the other advantages patterns have to offer.
• Reusing patterns assists in preventing minor issues that can cause major
problems in the application development process.What this means is when
code is built on proven patterns, we can afford to spend less time worrying about
the structure of our code and more time focusing on the quality of our overall
solution. This is because patterns can encourage us to code in a more structured
and organized fashion avoiding the need to refactor it for cleanliness purposes in
the future.
• Patterns can provide generalized solutions which are documented in a fash-
ion that doesn't require them to be tied to a specific problem. This generalized
approach means that regardless of the application (and in many cases the pro-

3
gramming language) you are working with, design patterns can be applied to im-
prove the structure of your code.
• Certain patterns can actually decrease the overall file-size footprint of your
code by avoiding repetition.By encouraging developers to look more closely at
their solutions for areas where instant reductions in repetition can be made, e.g.
reducing the number of functions performing similar processes in favor of a single
generalized function, the overall size of your codebase can be decreased.
• Patterns add to a developers vocabulary, which makes communication
faster.
• Patterns that are frequently used can be improved over time by harnessing
the collective experiences other developers using those patterns contribute
back to the design pattern community. In some cases this leads to the creation
of entirely new design patterns whilst in others it can lead to the provision of im-
proved guidelines on how specific patterns can be best used. This can ensure that
pattern-based solutions continue to become more robust than ad-hoc solutions
may be.

We already use patterns everyday


To understand how useful patterns can be, let's review a very simple element selection
problem that the jQuery library solves for us everyday.
If we imagine that we have a script where for each DOM element on a page with class
"foo" we want to increment a counter, what's the simplest efficient way to query for
the list we need?. Well, there are a few different ways this problem could be tackled:
1. Select all of the elements in the page and then store them. Next, filter this list and
use regular expressions (or another means) to only store those with the class "foo".
2. Use a modern native browser feature such as querySelectorAll() to select all of
the elements with the class "foo".
3. Use a native feature such as getElementsByClassName() to similarly get back the
desired list.
So, which of these is the fastest?. You might be interested to know that it's actually
number 3. by a factor of 8-10 times the alternatives. In a real-world application however,
3. will not work in versions of Internet Explorer below 9 and thus it's necessary to use
1. where 3. isn't supported.
Developers using jQuery don't have to worry about this problem, as it's luckily ab-
stracted away for us. The library opts for the most optimal approach to selecting ele-
ments depending on what your browser supports.
Core internally uses a number of different design patterns, the most frequent one
being a facade. This provides a simple set of abstracted interfaces (e.g $el.css(),
$el.animate()) to several more complex underlying bodies of code.

4 | Chapter 2: What is a Pattern?


Random documents with unrelated
content Scribd suggests to you:
SAID THE ROSE
No flower hath so fair a face as this pale love of mine
When he bends down to kiss my heart, my petals try to twine
About his lips to hold them fast. He is so very fair,
My lover with the pale, sad face and forest-fragrant hair.

I think it is a pleasant place, this garden where I grow,


With gravel walks and grassy mounds and crosses in a row.
There is no toil nor worry here, nor clatter of the street,
And here each night my lover comes, pale, sad and very sweet.

He never heeds the violets or lilies tall and white;


I am his love, his only love, his Flower of Delight;
And often when the cold moonbeams are lying all around
My lover kneels the whole night through beside me on the ground.

How can I miss the sunshine-laden breezes of the south


When all my heart is burning with the kisses of his mouth?
How can I miss the coming of the comfort-bringing rain
When his hot tears are filling me with heaven-sweet love-pain?

There is a jealous little bird that envies me my love,


He sings this bitter, bitter song from his brown nest above:
“Was ever yet a mortal man who wed a flower wife?
He loves the girl down in your roots whose dead breast gives you
life.”

O little bird, O jealous bird, fly off and cease your chatter!
My lover is my lover, and what can a dead girl matter?
In his hot kisses and sweet tears I shall my petals steep;
I am his love, his only love, I have his heart to keep.
WHITE MARBLE AND GREEN GRASS
Starlight, sunlight, silver light and gold,
All are dark for Love’s great flame is cold.
Rose wind, garden wind and morning’s breath,
Are ye stronger than the scent of death?
METAMORPHOSIS

He was an evil thing to see—


Of joy his mouth was desolate,
His body was a stunted tree,
His eyes were pools of lust and hate.

Now silverly the linnet sings


On leaves that from his temples start
And gay the yellow crocus springs
From the rich clod that was his heart.
ABSINTHE
I have prayed to the Christ of the merciful eyes,
I have prayed to the Lord of Hosts,
I have prayed, but in vain, for God to rise
And scatter these murderous ghosts,
These horrible, beckoning ghosts that sign
And beckon me where? ah, where?
O little green god in your crystal shrine,
You only will heed my prayer!

The breath of your mouth is a powerful wind


That whirls sorrow-shadows away;
The light of your eyes burns the bonds that bind,
I escape from the earth’s fell sway.
The pallid figures in threatening line,
They falter and tremble and flee.
O little green god in your crystal shrine,
Shed some of your glory on me!

I have given you service, sincere and prolonged,


I have given you love—ah, you know!
Though I pray in a fane by your worshippers thronged,
There is no one who worships you so.
My hand and my heart and my brain, ah, divine
Lord, master of living, I give,
O little green god in your crystal shrine,
Take these—and then bid me to live!

By a green marble house in a garden of green,


Green roses bloom ’neath a green sun,
Where the maidens have eyes of an emerald sheen,
And the strife and the labor are done,
O there let me dwell, where the ravenous whine
Of the earth ghosts is soundless and dead.
O little green god in your crystal shrine,
Your heavenly dream-shower shed!
THEOLOGY
The blade is sharp, the reaper stout,
And every daisy dies.
Their souls are fluttering about—
We call them butterflies.
FOR A CHILD
His mind has neither need nor power to know
The foolish things that men call right and wrong.
For him the streams of pleasant love-wind flow,
For him the mystic, sleep-compelling song.
Through love he rules his love-made universe,
And sees with eyes by ignorance made keen
The fauns and elves whom older eyes disperse,
Great Pan and all the fairies with their queen.
King gods, I pray, bestow on him this dole,
Not wisdom, wealth, nor mighty deeds to do,
But let him keep his happy pagan soul,
The poet-vision, simple, free and true,
To hunt the rainbow-gold and phantom lights,
And meet with dryads on the wooded heights.
TO J. B. Y.

Bitter and selfish sorrow, poverty, strife and ruth,


Fear of the dreadful morrow,—these took away our youth.
Ængus is bending o’er us—we are too old to see,
Too old to hear before us moon-drenchèd songs of Shee.

Dreamer of dreams and lover, young as are love and dreams,


Show us the Shee that hover over the silver streams,
Give us the song and story, make us to live anew,
Bathed in your youthful glory let us be young like you.
THE KING’S BALLAD
Good my king, in your garden close,
(Hark to the thrush’s trilling,)
Why so sad when the maiden rose
Love at your feet is spilling?
Golden the air and honey-sweet,
Sapphire the sky, it is not meet
Sorrowful faces should flowers greet,
(Hark to the thrush’s trilling.)

All alone walks the king to-day,


(Hark to the thrush’s trilling,)
Far from the throne he steals away
Loneness and quiet willing.
Roses and tulips and lilies fair
Smile for his pleasure everywhere,
Yet of their joyaunce he takes no share,
(Hark to the thrush’s trilling.)

Ladies wait in the palace, Sire,


(Hark to the thrush’s trilling,)
Red and white for the king’s desire
Lovewarm and sweet and thrilling,
Breasts of moonshine and hair of night,
Glances amorous soft and bright,
Nothing is lacking for thy delight,
(Hark to the thrush’s trilling.)

Kneels the king in a grassy place,


(Hark to the thrush’s trilling,)
Little flowers under his face
With his warm tears are filling:
Says the king, “Here my heart lies dead
Where my fair love is buried,
Would I were lying here instead!”
(Hark to the thrush’s trilling.)
JESUS AND THE SUMMER RAIN

Over the hills and across the plain,


Treading their gypsy way,
Ragged and penniless, vagrants twain
Went with a child one day.

Sunburnt and barefooted was the man,


Poor was the woman’s dress,
Over the baby the sunbeams ran,
Winds gave him soft caress.

“Brother o’ mine,” said the summer rain,


“Brother o’ mine,” said he,
“Take you the vagabond’s joy and pain,
Vagabond shall you be.

“Banned by the rich and the folk of power,


Outcasts shall love you well;
Harlots and thieves in your dying hour
Closest to you shall dwell.

“Never a home nor abiding place


Where you may rest your load;
Ever the starlight on your face,
Ever the open road.

“Brother o’ mine,” said the summer rain,


“Brother o’ mine,” said he,
“Take you the vagabond’s joy and pain,
Vagabond shall you be.”
THE BALLADE OF BUTTERFLIES
Because we never build a nest
And no one of us ever sings,
We are the butt of every jest
That strutting loud-mouthed robin flings.
Unless the field with laughter rings
And we are meek in our replies
His claws and beak to bear he brings;
Have pity on all butterflies!

Since we are of no home possest,


And have no joy in courts and kings,
And love on working-days to rest,
The name of “Idlers” to us clings.
On all our gypsy travellings
They follow us with jeering cries.
From every rose a spider springs;
Have pity on all butterflies!

A little thing is our request—


Some peace from nets of sticks and strings,
An hour to feel the sunlight’s zest,
To ’scape the deadly bee that stings.
From hostile fortune’s bolts and slings
Give us release ere Summer dies—
We dread the Winter’s threatenings;
Have pity on all butterflies!

L’ENVOI

Great Pan, kind lord of living things,


Look on us now with friendly eyes.
We pray to you on trembling wings,
Have pity on all butterflies!
THE CLOUDED SUN
(To A. S.)
It is not good for poets to grow old
For they serve Death that loves and Love that kills;
And Love and Death, enthroned above the hills,
Call back their faithful servants to the fold
Before Age makes them passionless and cold.

Therefore it is that no more sorry thing


Can shut the sunlight from the thirsty grass
Than some grey head through which no longer pass
Wild dreams more lively than the scent of Spring
To fire the blood and make the glad mouth sing.

Far happier he, who, young and full of pride


And radiant with the glory of the sun,
Leaves earth before his singing time is done.
All wounds of Time the graveyard flowers hide,
His beauty lives, as fresh as when he died.

Then through the words wherein his spirit dwells


The world may see his young impetuous face
Unmarred by Time, with undiminished grace;
While memory no piteous story tells
Of barren days, stale loves and broken spells.

Brother and Master, we are wed with woe.


Yea, Grief’s funereal cloud it is that hovers
About the head of us thy mournful lovers.
Uncomforted and sick with pain we go,
Dust on our brows and at our hearts the snow.

The London lights flare on the chattering street,


Young men and maidens love and dance and die;
Wine flows, and perfumes float up to the sky.
O th ld t f l th t thi t
Once thou couldst feel that this was very sweet,
Now thou art still—mouth, hands and weary feet.

O subtle mouth, whereon the Sphinx has placed


The smile of those she kisses at their birth,
Sing once again, for Spring has thrilled the earth.
Nay, thou art dumb. Not even April’s taste
Is sweet to thee in thy live coffin cased.

There is no harsher tragedy than this—


That thou, who feltest as no man before
Scent, color, taste and sound and didst outpour
For us rich draughts of thine enchanted bliss
Shouldst be plunged down this cruel black abyss.

Brother and Master, if our love could free


Thy flameborn spirit from its leaden chain
Thou shouldst rise up from this sad house of pain,
Be young and fair as thou wast wont to be,
And strong with joy as is the boundless sea.

Brother and Master, at thy feet we lay


These roses, red as lips that thou hast sung.
And cypress wreaths above thy head are hung
To mingle with the green and fragrant bay.
We kneel awhile, then turn in tears away.
IN MEMORIAM:
FLORENCE NIGHTINGALE

She whom we love, our Lady of Compassion,


Can never die, for Love forbids her death.
Love has bent down in his old kindly fashion,
And breathed upon her his immortal breath.

On wounded soldiers, in their anguish lying,


Her gentle spirit shall descend like rain.
Where the white flag with the red cross is flying,
There shall she dwell, the vanquisher of pain.
BALLAD OF THREE
Upon the river’s brink she stands
And tastes the dawn’s white breath.
She wrings her slender, silver hands,
“God’s curse on love,” she saith.
“Love binds me with his cruel bands
That break not save with death.”

“Now Geoffrey is a huntsman bold


And slays the mountain deer,
And Hugh plows up the fragrant mold
And plucks the ripened ear.
In friendship would these twain grow old
Did I not dwell anear.

“Hugh brings me grapes with sunlight sweet,


Like globes of amethyst,
While Geoffrey’s fawn with snowflake feet
Is corded to my wrist.
They mutter curses when they meet,
Their sight dims with red mist.

“And it is love hath done this thing;


Yea, Geoffrey loves my hair,
And Hugh lifts up his voice to sing
That my sad face is fair,
And love strews poison in the spring
And fouls the pleasant air.

“But not for my poor loveliness


Shall blood of brothers flow.
What is one woman, more or less?
And what is love but woe!
I want no murderer’s caress,
So for love’s sake—I go.”

Lads, sheathe your knives, no use to fight.


The lady you would wed
Shall sleep alone in state tonight
With candles at her head.
Lift, friends, this figure still and white
And bear her to her bed.
COURT MUSICIANS

As when in summer-scented days gone by


The court-musicians, dressed in velvets gay
And golden silks, would on their gitterns play
And blend their voices with the strings’ love-cry,
So that the princess from her tower on high
Might through the rose-framed window hear their lay,
And make more splendid the resplendent day
By leaning out, her choristers to spy;

So now, with weary voice and violin,


Two court-musicians rend the dusty air.
Their shrill notes pierce the elevated’s din,
And thrill a girl’s heart with a pleasure rare.
For her has sweeter music never been;
They never saw a princess half so fair.
THE DEAD LOVER

I tire of lovely faces free from pain


And free from sin;
Here none with lips wet with the crimson stain
May enter in.
One thing I lack, and lacking it, am dead—
A woman’s heart.
“She cannot enter here,” an angel said;
I will depart.

I have one prayer that I will make to God,


That I may stay
Where lies my body underneath the sod.
Then night and day
I shall be where my dear false love may pass;
It will be sweet
To hear above my head, upon the grass,
Her little feet.
THE POET’S EPITAPH

Dreams fade with morning light,


Never a morn for thee,
Dreamer of dreams, good-night.

Over our earthly sight


Shadows of woe must be;
Dreams fade with morning light.

Soldiers awake to fight—


Thou art from strife set free,
Dreamer of dreams, good-night.

Day breaketh, cruel, white,


Lovely the forms that flee;
Dreams fade with morning light.

Thine is the sure delight,


Sleep-visions still to see,
Dreamer of dreams, good-night.

Pity us from thy height,


Dawn-haunted slaves are we;
Dreams fade with morning light,
Dreamer of dreams, good-night.
THE SUBWAY

Tired clerks, pale girls, street cleaners, business men,


Boys, priests and harlots, drunkards, students, thieves,
Each one the pleasant outer sunshine leaves;
They mingle in this stifling, loud-wheeled pen.
The gate clangs to—we stir—we sway—and then
We thunder through the dark. The long train weaves
Its gloomy way. At last above the eaves
We see awhile God’s day, then night again.

Hurled through the dark—day at Manhattan Street,


The rest all night. That is my life, it seems.
Through sunless ways go my reluctant feet.
The sunlight comes in transitory gleams.
And yet the darkness makes the light more sweet,
The perfect light about me—in my dreams.
THE OTHER LOVER
I’m home from off the stormy sea,
And down the street
The folk come out to welcome me
On eager feet.
O neighbors, God be with you all,
But for my true love I must call;
She lingers in her father’s hall
So shy, so sweet!

Here is a string of milky pearls


For her to wear,
An amber comb to match the curls
Of her bright hair.
O neighbors, do not crowd me so!
Stand by! stand by! for I must go
To put on my love’s hand of snow
This gold ring fair.

Good dame, why do you block the way


And shake your head?
Must all the things you have to say
Just now be said?
O neighbors, let me pass—but why—
My God, what makes you women cry?
Come tell me that I too may die!
Is my love dead?

“Nay, Marjorie’s a living thing,


And fair and strong.
Yet did you wait to give your ring
A year too long.
To seek her love there came the Moon;
Now Marjorie at night and noon
Is chained and sits alone to croon
The Moon’s love-song.”
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!

ebookname.com

You might also like