Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript 2nd Edition Adam L. Davis - Download the ebook now for instant access to all chapters
Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript 2nd Edition Adam L. Davis - Download the ebook now for instant access to all chapters
com
https://textbookfull.com/product/modern-programming-made-
easy-using-java-scala-groovy-and-javascript-2nd-edition-
adam-l-davis/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/modern-programming-made-easy-using-
java-scala-groovy-and-javascript-second-edition-adam-l-davis/
textbookfull.com
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/
textbookfull.com
https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-eric-
freeman/
textbookfull.com
Head First JavaScript Programming, 2nd Edition: A
Learner’s Guide to Modern JavaScript Eric Freeman
https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-eric-
freeman-2/
textbookfull.com
https://textbookfull.com/product/scala-programming-a-comprehensive-
beginner-s-guide-to-scala-2nd-edition-claudia-alves/
textbookfull.com
https://textbookfull.com/product/u-s-immigration-made-easy-19th-
edition-us-immigration-made-easy-ilona-bray/
textbookfull.com
Modern
Programming
Made Easy
Using Java, Scala, Groovy,
and JavaScript
—
Second Edition
—
Adam L. Davis
ITeBooksFree.com
Modern Programming
Made Easy
Using Java, Scala, Groovy,
and JavaScript
Second Edition
Adam L. Davis
ITeBooksFree.com
Modern Programming Made Easy: Using Java, Scala, Groovy, and
JavaScript
Adam L. Davis
Oviedo, FL, USA
ITeBooksFree.com
Dedicated to all teachers.
Thank you for teaching!
ITeBooksFree.com
Table of Contents
About the Authorࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿xv
About the Technical Reviewerࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿xvii
Chapter 1: Introduction������������������������������������������������������������������������1
Problem-Solving ���������������������������������������������������������������������������������������������������1
About This Book ����������������������������������������������������������������������������������������������������2
ITeBooksFree.com
Table of Con en s
Chapter 4: Mathࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿17
Adding, Subtracting, etc �������������������������������������������������������������������������������������17
More Complex Math��������������������������������������������������������������������������������������������19
Random Numbers �����������������������������������������������������������������������������������������������20
Summary ������������������������������������������������������������������������������������������������������������22
vi
Table of Con en s
Chapter 7: Methodsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿41
Call Me ����������������������������������������������������������������������������������������������������������������41
Non-Java �������������������������������������������������������������������������������������������������������42
Break It Down �����������������������������������������������������������������������������������������������������43
Return to Sender�������������������������������������������������������������������������������������������������43
Static�������������������������������������������������������������������������������������������������������������������44
Varargs����������������������������������������������������������������������������������������������������������������45
Main Method �������������������������������������������������������������������������������������������������������45
Exercises�������������������������������������������������������������������������������������������������������������46
Summary ������������������������������������������������������������������������������������������������������������46
Chapter 8: Inheritanceࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿47
Objectify��������������������������������������������������������������������������������������������������������������48
JavaScript������������������������������������������������������������������������������������������������������49
Parenting 101������������������������������������������������������������������������������������������������������49
JavaScript������������������������������������������������������������������������������������������������������51
Packages ������������������������������������������������������������������������������������������������������������52
Public Parts���������������������������������������������������������������������������������������������������������53
JavaScript������������������������������������������������������������������������������������������������������53
Interfaces ������������������������������������������������������������������������������������������������������������54
Abstract Class �����������������������������������������������������������������������������������������������������55
Enums �����������������������������������������������������������������������������������������������������������������56
Annotations ���������������������������������������������������������������������������������������������������������57
Autoboxing ����������������������������������������������������������������������������������������������������������58
Autoboxing�����������������������������������������������������������������������������������������������������58
Unboxing��������������������������������������������������������������������������������������������������������58
Summary ������������������������������������������������������������������������������������������������������������58
vii
Table of Con en s
viii
Table of Con en s
Renaming a Function�������������������������������������������������������������������������������������88
Wrapping a Function in Another Function and Calling It �������������������������������88
Inline a Function Wherever It Is Called ����������������������������������������������������������89
Extract Common Code into a Function (the Opposite of the Previous) ����������89
ix
Table of Con en s
x
Table of Con en s
xi
Table of Con en s
Appendix A: Java/Groovyࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿173
No Java Analog �������������������������������������������������������������������������������������������������174
Appendix B: Java/Scalaࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿175
No Java Analog �������������������������������������������������������������������������������������������������176
Null, Nil, etc ������������������������������������������������������������������������������������������������������176
Appendix C: Java/JavaScriptࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿177
No Java Analog �������������������������������������������������������������������������������������������������178
Appendix D: Resourcesࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿179
xii
Table of Con en s
Appendix F: Javaࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿185
Afterwordࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿187
Indexࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿189
xiii
About the Author
Adam L. Davis makes software. He’s spent
many years developing in Java (since Java 1.2)
and has enjoyed using Spring and Hibernate
for more than a decade. Since 2006 he’s
been using Groovy, Grails, HTML, CSS, and
JavaScript, in addition to Java, to create SaaS
web applications that help track finances for
large institutions (among other things).
Adam has a master’s and a bachelor’s
degree in Computer Science from Georgia
Tech. He is also the author of Reactive Streams in Java (Apress, 2019) and
Learning Groovy 3, Second Edition (Apress, 2019). You can check out his
web site at https://github.adamldavis.com/.
xv
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic
developer and researcher who enjoys learning
new technologies for his own experiments and
creating new integrations. Manuel won the
Springy Award—Community Champion and
Spring Champion 2013. In his little free time,
he reads the Bible and composes music on his
guitar. Manuel is known as dr_pompeii. He
has tech-reviewed numerous books for Apress,
including Pro Spring Boot 2 (2019), Rapid
Java Persistence and Microservices (2019), Java Language Features (2018),
Spring Boot 2 Recipes (2018), and Java APIs, Extensions and Libraries
(2018). Read his 13 detailed tutorials about many Spring technologies,
contact him through his blog at www.manueljordanelera.blogspot.com,
and follow him on his Twitter account, @dr_pompeii.
xvii
CHAPTER 1
Introduction
In my experience, learning how to program (in typical computer science
classes) can be very difficult. The curriculum tends to be boring, abstract,
and unattached to “real-world” coding. Owing to how fast technology
progresses, computer science classes tend to teach material that is very
quickly out of date and out of touch. I believe that teaching programming
could be much simpler, and I hope this book achieves that goal.
Problem-Solving
Before you learn to program, the task can seem rather daunting, much like
looking at a mountain before you climb it. However, over time, you will
realize that programming is really about problem-solving.
On your journey toward learning to code, as with so much in life, you
will encounter many obstacles. You may have heard it before, but it really is
true: the path to success is to try, try, and try again. People who persevere
the most tend to be the most successful people.
Programming is fraught with trial and error. Although things will get
easier over time, you’ll never be right all the time. So, much as with most
things in life, you must be patient, diligent, and curious to be successful.
Info Text styled this way usually refers the curious reader to
additional information.
2
CHAPTER 2
Software to Install
Before you begin to program, you must install some basic tools.
Java/Groovy
For Java and Groovy, you will have to install the following:
1
https://adoptopenjdk.net/installation.html
© Adam L. Davis 2020 3
A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_2
Ch慰ter 2 S潦t睡re t I湳t ll
Trying It Out
After installing Groovy, you should use it to try coding. Open a command
prompt (or terminal), type groovyConsole, and hit Enter to begin.
Because most Java code is valid Groovy code, you should keep the
Groovy console open and use it to try out all of the examples from this
book.
You can also easily try out JavaScript in the following way:
2
https://netbeans.apache.org/download/index.html
3
https://groovy.apache.org/download.html
4
Ch慰ter 2 S潦t睡re t I湳t ll
Others
Once you have the preceding installed, you should eventually install the
following:
• Scala4: An object-oriented language built on the JVM
• Git5: A version control program
Code on GitHub
A lot of the code from this book is available on github.com/modernprog.7
You can go there at any time to follow along with the book.
4
www.scala-lang.org/
5
https://git-scm.com/
6
https://maven.apache.org/
7
https://github.com/modernprog
5
CHAPTER 3
The Basics
In this chapter, we’ll cover the basic syntax of Java and similar languages.
Coding Terms
Source file refers to human-readable code. Binary file refers to computer-
readable code (the compiled code). In Java, this binary code is called
bytecode which is read by the Java Virtual Machine (JVM).
In Java, the source files end with .java, and binary files end with
.class (also called class files). You compile source files using a compiler,
which gives you binary files or bytecode.
In Java, the compiler is called javac; in Groovy it is groovyc; and it is
scalac in Scala (see a trend here?). All three of these languages can be
compiled to bytecode and run on the JVM. The bytecode is a common
format regardless of which programming language it was generated from.
However, some languages, such as JavaScript, don’t have to be
compiled. These are called interpreted languages. JavaScript can run in
your browser (such as Firefox or Google Chrome), or it can run on a server
using Node.js, a JavaScript runtime built on Chrome’s V8 JavaScript engine.
1
A bit is the smallest possible amount of information. It corresponds to a 1 or 0.
2
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.
html
8
Chap er 3 The Ba i捳
Groovy types are much the same as Java’s. n Scala, everything is an object,
so primitives don’t exist. owever, they are replaced with corresponding value
types (Int, Long, etc.). JavaScript has only one type of number, Number,
which is similar to Java’s float.
Strings/Declarations
A String is a list of characters (text). It is a very useful built-in class in Java
(and most languages). To define a string, you simply surround some text in
quotes. For example:
9
Chap er 3 The Ba i捳
In Java, you must put the type of the variable in the declaration. That’s
why the first word here is String.
In Groovy and JavaScript, strings can also be surrounded by single
quotes ('hello'). Also, declaring variables is different in each language.
Groovy allows you to use the keyword def, while JavaScript and Scala use
var. Java 10 also introduced using var to define local variables. For example:
Statements
Almost every statement in Java must end in a semicolon (;). In many
other languages, such as Scala, Groovy, and JavaScript, the semicolon is
optional, but in Java, it is necessary. Much as how periods at the end of
each sentence help you to understand the written word, the semicolon
helps the compiler understand the code.
By convention, we usually put each statement on its own line, but this
is not required, as long as semicolons are used to separate each statement.
Assignment
Assignment is an extremely important concept to understand, but it can
be difficult for beginners. However, once you understand it, you will forget
how hard it was to learn.
Let’s start with a metaphor. Imagine you want to hide something
valuable, such as a gold coin. You put it in a safe place and write the
address on a piece of paper. This paper is like a reference to the gold. You
can pass it around and even make copies of it, but the gold remains in the
same place and does not get copied. On the other hand, anyone with the
reference to the gold can get to it. This is how a reference variable works.
10
Chap er 3 The Ba i捳
After running the preceding code, gold and a refer to the string "Au",
while b refers to "Br".
1ꂠpackage com.example.mpme;
2ꂠpublic classꂠSmallClassꂠ{
3ꂠ}
11
Chap er 3 The Ba i捳
Create a Class
1ꂠpackageꂠcom.example.mpme;
2ꂠpublicꂠclassꂠSmallClassꂠ{
3ꂠꂠꂠString name; //field
4ꂠꂠꂠString getName() {returnꂠname;} //getter
5ꂠꂠꂠvoid print() {System.out.println(name);} //method
6ꂠ}
12
Chap er 3 The Ba i捳
This method changes the name field, prints out the new value, and
then returns that value. Try this new method out in the groovyConsole by
defining the class and then executing the following:
Groovy Classes
Groovy is extremely similar to Java but always defaults to public (we will
cover what public means in a later chapter).
1ꂠpackage com.example.mpme;
2ꂠclass SmallClass {
3ꂠꂠꂠString name //property
4ꂠꂠꂠdef print() { println(name) } //method
5ꂠ}
13
Chap er 3 The Ba i捳
Groovy also automatically gives you “getter” and “setter” methods for
properties, so writing the getName method would have been redundant.
JavaScript Prototypes
Although JavaScript has objects, it doesn’t have a class keyword (prior to
ECMAScript 2015). Instead, it uses a concept called prototype. For example,
creating a class can look like the following:
1ꂠfunction SmallClass() {}
2ꂠSmallClass.prototype.name = "name"
3ꂠꀇSmallClass.prototype.print = function() { console.log(this.
name) }
Scala Classes
Scala has a very concise syntax, which puts the properties of a class in
parentheses. Also, types come after the name and a colon. For example:
1ꂠsc = newꂠSmallClass();
14
Chap er 3 The Ba i捳
Comments
As a human, it is sometimes useful for you to leave notes in your source
code for other humans—and even for yourself, later. We call these notes
comments. You write comments thus:
Summary
In this chapter, you learned the basic concepts of programming:
• Compiling source files into binary files
• How objects are instances of classes
• Primitive types, references, and strings
• Fields, methods, and properties
• Variable assignment
• How source code comments work
15
Another Random Document on
Scribd Without Any Related Topics
family, but to you I feel that an explanation is due. At any rate, you
are a Wentworth and have given me ample proof that you may with
safety be entrusted with a secret.
“It seems years ago that one of my ancestors got entangled in
some way or another with a beautiful gipsy. She begged him to
marry her; he refused; and fearful lest the affair should leak out and
so bring discredit upon the family, he murdered her, burying her
body, together with that of her child, underneath the ballroom floor.
At least so the MS. states, and no one, as far as I am aware, has
ever disproved it.
“Tortured with remorse and a victim to the orthodox fears of a
murderer, my unhappy forefather took poison, commanding in his
will ‘that the ballroom should never again be used for a frivolous
purpose,’ an injunction which, until last night, has been faithfully
obeyed.
“The Wentworths, as you may naturally suppose, have kept the
story strictly to themselves—the male heirs alone being usually
acquainted with it.
“I did not altogether credit the story of the haunting though my
father swore he had seen the cursed apparitions. Moreover he told
me that they appeared periodically—every night at 11 p.m. from the
20th to the 31st of December. He also warned me, and here I am
much to blame, on no account to permit any outsider to be in the
room, ‘for if you do,’ he added, ‘then, something terrible will happen.’
I own I was sceptical and bitterly I regret it now. I had never seen
an apparition, and what my father told me he had seen, I attributed
to Suggestion, the natural consequence of dwelling too much on the
horrible details of the story.
“Maud shared my scepticism and when she wanted to use the
room, brought forward the most ingenious arguments to overcome
my scruples.
“I declared it was impossible—it would be sheer sacrilege. I was
accused of inconsistency. I disbelieved! how then could there be any
danger!—the injunction in the will was unreasonable and absurd. In
short, I had no peace, I had to yield, so making the stipulation that
we should first find out some means by which we could prove that
there was no foundation for the story of the haunting, I reluctantly
gave my consent.
“Somewhat to my astonishment, Maud had already formed a plan
for testing the room. She had heard me speak of you, you were a
Wentworth; if you discovered anything we could rely on you to keep
it secret—and so my wife suggested that you should be put in the
room, ‘just to sample it.’ I hesitated, I did not speak. I suppose my
silence gave consent: the rest you know. I won’t press you to tell me
if you saw those beastly things, if you did the sequel only serves us
right. Anyhow nothing can excuse my having sanctioned
disobedience to that injunction in the will.
“The fact and the nature of the haunting is a secret no longer—
the cause none but a Wentworth shall ever know.
“I need hardly enjoin you who are one of us to maintain silence on
that point.
“We shall shut up the house for a time, until, in fact, the worst of
the affair has blown over—and—when we meet again, let us hope it
will be under happier circumstances.”
We never met again; within six months of my departure, both
Robert and his son were dead—killed in a motor accident abroad.
The property is now in the hands of distant, of very distant relations,
and I feel no compunction in saying what I know about it.
Only—if you repeat this to Mr. Elliott O’Donnell, please substitute
fictitious names.
BURLE FARM, NORTH DEVON
THE HEADLESS DOG AND THE EVIL TREE
Between my exit from the stage in 1900 up till quite recently I had
the great, the very great misfortune to be a teacher in a small town
in the north of England.
I say misfortune because I found the contrasts between exciting
stageland and the monotonous schoolroom, between the generous
and jovial theatrical fraternity and the mean and petty local parents,
too decidedly pronounced to be other than excessively unpleasant.
I had small patience with the mediocre abilities of very mediocre
children, and still less with the continual and unwarrantable
interference of their ill-mannered and doting mothers. No lot in life
could have been more thoroughly uncongenial than mine; indeed, it
would have soon become unbearable had it not been for the
constant influx of strangers whose presence in the town made an
oasis in the desert.
It is to one of these visitors—Miss Medley—that I owe the
following story.
“Some years ago,” she began, “I received an invitation to spend
August with a very crochety old aunt of mine residing at Burle Farm,
North Devon.
“There was nothing at all extraordinary in the appearance of the
house; it belonged to a type common in all parts of England. It was
a low, rambling building of yellow stone with a good, substantial,
thatched roof and ample stabling. The rooms, sweet with the scent
of jasmine and honeysuckle, compared more than favourably with
the stuffy dens in which I had been obliged to live in London; whilst
the diamond-shaped window-panes and massive oak beams serving
as supports to the ceilings, struck me as being quite delightfully
quaint.
“My aunt, too—a rosy-faced old lady in a mob-cap—appeared
quite in harmony with her surroundings. She was kindness itself—
indeed, no one could have made me feel more thoroughly at home.
“‘Folks do say the house is haunted,’ she laughed, ‘particularly one
room—but there! I have never seen anything, and I don’t suppose
you will.’
“‘A ghost!’ I cried, ‘how awfully exciting! oh! do let me sleep in the
haunted room,’ and I continued to plead till the kind-hearted old lady
reluctantly consented.
“‘You mustn’t blame me if the ghost should visit you, Rosie,’ she
said; ‘remember I have warned you.’
“‘There is nothing I should enjoy better than seeing a real bona-
fide spook, auntie dear,’ I rejoined, smiling; but my aunt shook her
head reprovingly, and no more was said on the subject until the next
day.
“I awoke that night as the clock struck two—indeed, I fancied my
awakening was due to that striking, it seemed so unusually loud and
emphatic.
“It was a fine—indeed, I might say glorious—night, for although
there was no moon, the heavens were so brilliantly illuminated with
myriads of scintillating stars, that I could see every object around
me almost as clearly as if it had been day.
“A sudden movement near the foot of the bed made me recollect
my aunt’s admonition. I listened, experiencing none of those
pleasant anticipations of which I had spoken so boastfully.
“I knew no one could have entered the room, as I had taken the
precaution to lock the door, having first of all looked under the bed
and made a thorough examination of the hanging wardrobe.
Consequently my visitor, unless a mouse or a rat, could be nothing
material.
“I devoutly wished I had slept in one of the other rooms.
“A faint and sickly odour now became perceptible whilst the noise
hitherto uninterpretable developed into a series of unequal knocks
just as if some big animal were lying on the floor ‘scratching’ itself.
“Determined not to appear frightened I put my hand out of bed
and called ‘Trot! Trot! is that you?’ (Trot being the name of my
auntie’s retriever.)
“Something instantly jumped up and, coming round the bed, stood
by my side. Wondering whether it could be Trot, though at a loss to
understand how he could have got into the room without being
seen, I stretched out my fingers and to my intense relief touched a
furry coat—the stench at the same time becoming so truly awful that
I retched.
“I could, of course have satisfied myself as to the identity of my
visitor by merely looking, but this, I am ashamed to say, I was too
great a coward to do; a strange feeling telling me that I was in the
presence of something unnatural.
“Running my hand fearfully along the shaggy skin of the animal, I
felt for its head, discovering to my intense horror that it had none,
the neck terminating in a wet mass of something soft and spongy.
“Unable to restrain myself any longer, I now looked, perceiving to
my infinite terror a huge shock-haired spaniel, headless, and in the
most abominable state of decomposition.
“I gazed at it for some seconds too appalled either to stir or utter
a sound—this paralytic condition continuing till an abortive effort of
the phantasm to jump on the bed loosened my tongue and I
shrieked for help.
“The dog immediately vanished.
“My feelings had been, however, so outraged by what I had
witnessed that nothing would have induced me to pass the
remainder of the night in that room—my own idea was to get out of
it with the utmost celerity.
“I did so—nor did I ever again—not even by daylight—venture to
cross its threshold.
“My aunt, poor dear, was very much upset at the occurrence.
“She could not imagine how it was other people could see the
ghost while she could not. And her scepticism was but natural; she
was unable to grasp the idea that the psychic faculty is a gift, only
granted to the few, and as rare as that either of music or painting.
“Other reasons for her incredulity in this particular occult
manifestation lay in the enigmatical nature and purport of the
phenomenon.
“In what category of ghosts would one classify a headless dog;
Was it the spirit of a dog that had been decapitated on earth?
“She had never gathered from the Scriptures that beasts had souls
—what then was this phantom of a dog?
“I suggested it might be a Poltergeist or Elemental, one of those
purely bestial creations that for various reasons which you explained
at your recent lecture—always haunt certain localities?”
“Yes!” I said, interrupting Miss Medley, “the sub-animal type of
elemental is fairly common—if you refer to the June number 1908 of
the magazine published by the Society for Psychical Research you
will see an extremely well authenticated case of the haunting of a
village by a white pig with an abnormally long snout and I could
enumerate many other similar instances. But continue!”
“My aunt,” Miss Medley went on, “informed me that the house had
once been occupied by a lady who had lived a very selfish—not to
say sensual life. She had settled down at Burle, after having been
divorced twice, and her weekly routine was one incessant whirl of
pleasure.
“She died without the consolation of the Church, surrounded by a
crowd of fawning money-hunters and over-gorged poodles, so that
for this, as well as other reasons I think there may be an alternative
solution to the haunting. Is it not possible that what I saw was
actually the spirit of this worldly woman, which thoroughly brutalised
by long indulgence in sensuality had gradually adapted that shape
most befitting it.”
“And the moral of that, Miss Medley,” I observed, “is—if you do not
wish to become a beast do not live like one! Yes! there is much to be
learned from a study of the different types of phantasms—more I
believe than from any pulpit discourses. Is that your only psychic
experience?”
Miss Medley shook her head. “No!” she said, “I had another very
gruesome one at Burle. After the dog episode my aunt thought fit to
warn me not to pass along a certain road after dusk. ‘There is an
elm standing close to it,’ she said, ‘which the people about here
declare to be haunted; as you have seen one ghost you may see
another—so please be careful!’
“Now you might think that after such a disagreeable experience I
would have followed my aunt’s advice, but curiosity getting the
better of discretion I disobeyed her and, selecting a fine evening for
the enterprise, set out to the tree.
“As it was two or three miles away, and I was dearly fond of
riding, I hired a horse and going along at a jog-trot approached the
forbidden spot at about eight o’clock.
“The lane in which the haunted elm stood was narrow, trees of all
sorts and sizes lined it on either side, and the shadows, intensified
by the thickness of the foliage overhead, almost obliterated the
roadway.
“All was dark and silent. I no longer wondered at the villagers
fighting shy of such a place; it looked a positive cock-pit of
spookdom.
“At about twenty or so yards from the notorious elm my horse
showed unmistakable signs of uneasiness, laying back its ears and
shivering to such an extent that it was only by dint of alternate
threats and caresses that I succeeded in urging it forward. Arriving
at a spot level with the tree the animal shied, and had I not been a
pretty good horse-woman I might have met with a nasty accident,
but I stuck to my seat like a leech, and using my whip smartly drew
in the reins. My horse fell back on its haunches; reared—plunged
headlong forward—took the bit between its teeth and—we were off
like the wind.
“Fortunately I was prepared; leaning back in my saddle I enjoyed
rather than otherwise so mad a career. But my pleasure received a
sudden check when I perceived, to my horror, the figure of a tall
woman dressed in black striding along by the side of us and keeping
pace with us without any apparent effort.
“Heaven alone knew where she came from unless from the tree; I
fancied I had heard something drop from the branches at the
moment my horse shied. As the woman was wearing a cloak drawn
over her head, I could not see her face but from the grotesque
outlines of her limbs and body, I concluded it must be unpleasantly
bizarre.
“We kept together in this extraordinary fashion until we came in
sight of Burle, when she quickened her steps, and tearing off the
hood thrust her face upwards into mine.
“It was awful—utterly and inconceivably awful—so awful that I felt
the very marrow in my bones freeze with horror while my heart
stood still.
“She had no hair; her head was round and shiny, whilst her face,
yellow and swollen, was covered all over with circular black spots
causing it to bear a striking resemblance to one of those old-
fashioned carriage dogs!!! Her eyes were black and sinister; she had
no nose, whilst her mouth was—horrid—the most horrid thing about
her.
“With a diabolical grin she grabbed at my jacket and would, I
believe, have torn me from my seat had we not at this moment, in
the very nick of time, arrived within sight of the gates of Burle Farm.
“My aunt, with several other people, was awaiting me, and as with
a desperate spurt I galloped up to them, the infernal hag let go her
hold of my jacket, slackened her pace and vanished.”
CARNE HOUSE, NEAR
NORTHAMPTON
THE MAN IN THE FLOWERY DRESSING-GOWN
AND THE BLACK CAT
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.
textbookfull.com