100% found this document useful (3 votes)
23 views

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

The document promotes a collection of ebooks available for download at textbookfull.com, including titles such as 'Modern Programming Made Easy' by Adam L. Davis and 'Learning Concurrent Programming in Scala'. It provides links to various programming resources and emphasizes the availability of different formats for reading on any device. Additionally, it includes copyright information and details about the authors and technical reviewers of the featured books.

Uploaded by

umekinosis
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
23 views

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

The document promotes a collection of ebooks available for download at textbookfull.com, including titles such as 'Modern Programming Made Easy' by Adam L. Davis and 'Learning Concurrent Programming in Scala'. It provides links to various programming resources and emphasizes the availability of different formats for reading on any device. Additionally, it includes copyright information and details about the authors and technical reviewers of the featured books.

Uploaded by

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

Explore the full ebook collection and download it now at textbookfull.

com

Modern Programming Made Easy: Using Java, Scala,


Groovy, and JavaScript 2nd Edition Adam L. Davis

https://textbookfull.com/product/modern-programming-made-
easy-using-java-scala-groovy-and-javascript-2nd-edition-
adam-l-davis/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Modern Programming Made Easy Using Java Scala Groovy and


JavaScript Second Edition Adam L Davis

https://textbookfull.com/product/modern-programming-made-easy-using-
java-scala-groovy-and-javascript-second-edition-adam-l-davis/

textbookfull.com

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/

textbookfull.com

Learning concurrent programming in Scala learn the art of


building intricate modern scalable and concurrent
applications using Scala Second Edition Prokopec
https://textbookfull.com/product/learning-concurrent-programming-in-
scala-learn-the-art-of-building-intricate-modern-scalable-and-
concurrent-applications-using-scala-second-edition-prokopec/
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/
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

Scala Programming A comprehensive beginner s guide to


Scala 2nd Edition Claudia Alves

https://textbookfull.com/product/scala-programming-a-comprehensive-
beginner-s-guide-to-scala-2nd-edition-claudia-alves/

textbookfull.com

Beginning Functional JavaScript. Functional Programming


with JavaScript using EcmaScript 6 1st Edition Anto
Aravinth
https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-edition-
anto-aravinth/
textbookfull.com

Beginning Functional JavaScript: Functional Programming


with JavaScript Using EcmaScript 6 1st Edition Anto
Aravinth
https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-edition-
anto-aravinth-2/
textbookfull.com

U S Immigration Made Easy 19th Edition US Immigration Made


Easy Ilona Bray

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

ISBN-13 (pbk): 978-1-4842-5568-1उ ISBN-13 (electronic): 978-1-4842-5569-8


https://doi.org/10.1007/978-1-4842-5569-8

Copyright © 2020 by Adam L. Davis


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image, we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the author nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media, 1 New York Plaza,
New York, NY 10004, U.S.A.. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint, paperback, or
audio rights, please email [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on GitHub via the book’s product page, located at www.apress.com/9781484255681. For
more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper

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

Chapter 2: Software to Installࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿3


Java/Groovy ����������������������������������������������������������������������������������������������������������3
Trying It Out�����������������������������������������������������������������������������������������������������������4
Others �������������������������������������������������������������������������������������������������������������������5
Code on GitHub �����������������������������������������������������������������������������������������������������5

Chapter 3: The Basicsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿7


Coding Terms ��������������������������������������������������������������������������������������������������������7
Primitives and Reference��������������������������������������������������������������������������������������8
Strings/Declarations ���������������������������������������������������������������������������������������������9
Statements����������������������������������������������������������������������������������������������������������10
Assignment ���������������������������������������������������������������������������������������������������������10
Class and Object �������������������������������������������������������������������������������������������������11
Fields, Properties, and Methods ��������������������������������������������������������������������12
Groovy Classes ����������������������������������������������������������������������������������������������13
JavaScript Prototypes������������������������������������������������������������������������������������14
Scala Classes ������������������������������������������������������������������������������������������������14

ITeBooksFree.com
Table of Con en s

Creating a New Object�����������������������������������������������������������������������������������14


Comments�����������������������������������������������������������������������������������������������������������15
Summary ������������������������������������������������������������������������������������������������������������15

Chapter 4: Mathࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿17
Adding, Subtracting, etc �������������������������������������������������������������������������������������17
More Complex Math��������������������������������������������������������������������������������������������19
Random Numbers �����������������������������������������������������������������������������������������������20
Summary ������������������������������������������������������������������������������������������������������������22

Chapter 5: Arrays, Lists, Sets, and Mapsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿23


Arrays������������������������������������������������������������������������������������������������������������������23
Lists ��������������������������������������������������������������������������������������������������������������������25
Groovy Lists ���������������������������������������������������������������������������������������������������26
Scala Lists �����������������������������������������������������������������������������������������������������26
JavaScript Arrays ������������������������������������������������������������������������������������������27
Sets���������������������������������������������������������������������������������������������������������������������28
Maps �������������������������������������������������������������������������������������������������������������������29
Groovy Maps��������������������������������������������������������������������������������������������������30
Scala Maps����������������������������������������������������������������������������������������������������30
JavaScript Maps��������������������������������������������������������������������������������������������30
Summary ������������������������������������������������������������������������������������������������������������31

Chapter 6: Conditionals and Loopsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿33


If, Then, Else ��������������������������������������������������������������������������������������������������������33
Switch Statements����������������������������������������������������������������������������������������������34
Boolean Logic �����������������������������������������������������������������������������������������������������36
Looping ���������������������������������������������������������������������������������������������������������������37
Summary ������������������������������������������������������������������������������������������������������������39

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

Chapter 9: Design Patternsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿59


Observer �������������������������������������������������������������������������������������������������������������59
MVC���������������������������������������������������������������������������������������������������������������������61
DSL����������������������������������������������������������������������������������������������������������������������63
Closures���������������������������������������������������������������������������������������������������������63
Overriding Operators �������������������������������������������������������������������������������������65
Actors������������������������������������������������������������������������������������������������������������������66
Chain of Responsibility ���������������������������������������������������������������������������������������67
Facade ����������������������������������������������������������������������������������������������������������������68
Summary ������������������������������������������������������������������������������������������������������������69

Chapter 10: Functional Programmingࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿71


Functions and Closures���������������������������������������������������������������������������������������72
Map, Filter, etc ����������������������������������������������������������������������������������������������������74
Immutability ��������������������������������������������������������������������������������������������������������78
Java ��������������������������������������������������������������������������������������������������������������������80
Groovy �����������������������������������������������������������������������������������������������������������������81
Scala �������������������������������������������������������������������������������������������������������������������82
Summary ������������������������������������������������������������������������������������������������������������84

Chapter 11: Refactoringࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿85


Object-Oriented Refactoring �������������������������������������������������������������������������������85
Functional Refactoring����������������������������������������������������������������������������������������86
Refactoring Examples �����������������������������������������������������������������������������������������86
Renaming a Method ��������������������������������������������������������������������������������������87
Moving a Method from One Class to Another (Delegation)����������������������������87
Replacing a Bunch of Literals (Strings or Numbers)
with a Constant (Static Final) ������������������������������������������������������������������������88

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

Chapter 12: Utilitiesࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿91


Dates and Times �������������������������������������������������������������������������������������������������91
Java Date-Time ���������������������������������������������������������������������������������������������92
Groovy Date ���������������������������������������������������������������������������������������������������92
JavaScript Date ���������������������������������������������������������������������������������������������94
Java DateFormat �������������������������������������������������������������������������������������������94
Currency��������������������������������������������������������������������������������������������������������������96
TimeZone ������������������������������������������������������������������������������������������������������������96
Scanner���������������������������������������������������������������������������������������������������������������97

Chapter 13: Buildingࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿99


Ant�����������������������������������������������������������������������������������������������������������������������99
Maven ���������������������������������������������������������������������������������������������������������������100
Using Maven������������������������������������������������������������������������������������������������101
Starting a New Project ��������������������������������������������������������������������������������101
Life Cycle�����������������������������������������������������������������������������������������������������102
Executing Code��������������������������������������������������������������������������������������������103
Gradle����������������������������������������������������������������������������������������������������������������105
Getting Started with Gradle �������������������������������������������������������������������������105
Projects and Tasks���������������������������������������������������������������������������������������105
Plugins���������������������������������������������������������������������������������������������������������106
Dependencies����������������������������������������������������������������������������������������������107
Do First and Last �����������������������������������������������������������������������������������������108

ix
Table of Con en s

Chapter 14: Testingࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿111


Types of Tests����������������������������������������������������������������������������������������������������111
JUnit������������������������������������������������������������������������������������������������������������������112
Hamcrest �����������������������������������������������������������������������������������������������������113
Assumptions������������������������������������������������������������������������������������������������114
Spock ����������������������������������������������������������������������������������������������������������������115
Spock Basics �����������������������������������������������������������������������������������������������115
A Simple Test�����������������������������������������������������������������������������������������������116
Mocking�������������������������������������������������������������������������������������������������������117
Lists or Tables of Data ���������������������������������������������������������������������������������118
Expecting Exceptions ����������������������������������������������������������������������������������119
Other Test Frameworks�������������������������������������������������������������������������������������120
Summary ����������������������������������������������������������������������������������������������������������120

Chapter 15: Input/Outputࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿121


Files ������������������������������������������������������������������������������������������������������������������121
Reading Files ����������������������������������������������������������������������������������������������������122
Writing Files ������������������������������������������������������������������������������������������������������123
Downloading Files���������������������������������������������������������������������������������������������125
Summary ����������������������������������������������������������������������������������������������������������126

Chapter 16: Version Controlࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿127


Subversion ��������������������������������������������������������������������������������������������������������128
Git����������������������������������������������������������������������������������������������������������������������128
Mercurial�����������������������������������������������������������������������������������������������������������130

Chapter 17: The Interwebࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿131


Web 101 ������������������������������������������������������������������������������������������������������������132
My First Web App ����������������������������������������������������������������������������������������������133

x
Table of Con en s

The Holy Grails ��������������������������������������������������������������������������������������������������135


Quick Overview��������������������������������������������������������������������������������������������135
Plug-ins �������������������������������������������������������������������������������������������������������139
Cloud�����������������������������������������������������������������������������������������������������������������140
The REST�����������������������������������������������������������������������������������������������������������141
Using Maven Archetypes �����������������������������������������������������������������������������142
Using Grails JSON Views �����������������������������������������������������������������������������142
Summary ����������������������������������������������������������������������������������������������������������143

Chapter 18: Swinging Graphicsࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿145


Hello Window ����������������������������������������������������������������������������������������������������145
Push My Buttons �����������������������������������������������������������������������������������������������148
Fake Browser����������������������������������������������������������������������������������������������������149
Griffon ���������������������������������������������������������������������������������������������������������������152
Advanced Graphics �������������������������������������������������������������������������������������������153
Graphics Glossary ���������������������������������������������������������������������������������������������154
Summary ����������������������������������������������������������������������������������������������������������155

Chapter 19: Creating a Magical User Experienceࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿157


Application Hierarchy����������������������������������������������������������������������������������������157
Consider Your Audience ������������������������������������������������������������������������������������158
Choice Is an Illusion ������������������������������������������������������������������������������������������159
Direction������������������������������������������������������������������������������������������������������������159
Skeuomorphism������������������������������������������������������������������������������������������������160
Context Is Important������������������������������������������������������������������������������������������160
KISS ������������������������������������������������������������������������������������������������������������������160
You Are Not the User �����������������������������������������������������������������������������������������161
Summary ����������������������������������������������������������������������������������������������������������161

xi
Table of Con en s

Chapter 20: Databasesࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿163


SQL (Relational) Databases�������������������������������������������������������������������������������164
SQL ��������������������������������������������������������������������������������������������������������������165
Foreign Keys������������������������������������������������������������������������������������������������167
Connections�������������������������������������������������������������������������������������������������168
NoSQL (Non-relational) Databases��������������������������������������������������������������������169
Redis������������������������������������������������������������������������������������������������������������169
MongoDB �����������������������������������������������������������������������������������������������������170
Cassandra����������������������������������������������������������������������������������������������������170
VoltDB����������������������������������������������������������������������������������������������������������170
Summary ����������������������������������������������������������������������������������������������������������171

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

Appendix E: Free Online Learningࣿ﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿﷿181


The Death of College?���������������������������������������������������������������������������������������181
Sustainability ����������������������������������������������������������������������������������������������������182
More Online Resources �������������������������������������������������������������������������������������182

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.

Note There’s going to be a lot of tongue-in-cheek humor


throughout this book, but this first part is serious. Don’t worry, it gets
better.

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.

© Adam L. Davis 2020 1


A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_1
Chap er 1 In ro u捴on

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.

About This Book


This book is organized into several chapters, beginning with the most basic
concepts. If you already understand a concept, you can safely move ahead
to the next chapter. Although this book concentrates on Java, it also refers
to other languages, such as Groovy, Scala, and JavaScript, so you will gain a
deeper understanding of concepts common to all programming languages.

Tips Text styled like this provides additional information that


you may find helpful.

Info Text styled this way usually refers the curious reader to
additional information.

Warnings Text such as this cautions the wary reader. Many


have fallen along the path of computer programming.

Exercises This is an exercise. We learn best by doing, so it’s


important that you try these out.

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:

• JDK (Java Development Kit), such as OpenJDK 11. You


can install OpenJDK by following the instructions at
adoptopenjdk.net.1
• IDE (Integrated Development Environment), such as
NetBeans 11.

• Groovy: A dynamic language similar to Java that runs


on the JVM (Java Virtual Machine).

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

Install Java and NetBeans 11 or higher. Download and install the


Java JDK and NetBeans.2 Open NetBeans and select File ➤ New
Project… ➤ Java with Gradle, Java Application. When asked, provide
the group “test,” version “0.1,” and package such as “com.
gradleproject1”. Click “Finish,” then “OK.”
Install Groovy: Go to the Groovy web site and install Groovy.3

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.

In groovyConsole, type the following and then hit Ctrl+r to run


the code.
1 print “hello”

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:

• Just open your web browser and go to jsfiddle.net.

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

• Maven6: A modular build tool

Go ahead and install these, if you’re in the mood. I’ll wait.


To try out Scala, type scala in your command prompt or terminal once
you have installed it.

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.

© Adam L. Davis 2020 7


A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_3
Chap er 3 The Ba i捳

Primitives and Reference


Primitive types in Java refer to different ways to store numbers and have
practical significance. The following primitives exist in Java:
• char: A single character, such as A (the letter A).

• byte: A number from -128 to 127 (8 bits1). Typically, a


way to store or transmit raw data.

• short: A 16 bits signed integer. It has a maximum of


about 32,000.

• int: A 32 bits signed integer. Its maximum is about 2 to


the 31st power.

• long: A 64 bits signed integer. Maximum of 2 to the 63rd


power.

• float: A 32 bits floating-point number. This format


stores fractions in base two and does not translate
directly to base ten numbers (how numbers are usually
written). It can be used for things such as simulations.

• double: Like float but with 64 bits.


• boolean: Has only two possible values: true and false
(much like 1 bit).

See Java Tutorial—Data Types2 for more information.

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, SCALA, AND JAVASCRIPT

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.

A variable is a value in memory referred to by a name. In Java you can


declare a variable as a primitive by writing the type then any valid name.
For example, to create an integer named price with an initial value of 100,
write the following:

1ꂠint price = 100;

Every other type of variable in Java is a reference. It points to some


object in memory. This will be covered later on.
In Java, each primitive type also has a corresponding class type: Byte
for byte, Integer for int, Long for long, and so on. Using the class type
allows the variable to be null (meaning no value). However, using the
primitive type can have better performance when handling a lot of values.
Java can automatically wrap and unwrap primitives in their corresponding
classes (this is called boxing and unboxing).

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:

1ꂠString hello = "Hello World!";

Here the variable hello is assigned the string "Hello World!".

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:

1ꂠdef hello = "Hello Groovy!" //groovy


2ꂠvar hello = "Hello Scala/JS!" //Scala or JS

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捳

Let’s look at an example:

1ꂠString gold = "Au";


2ꂠString a = gold;
3ꂠString b = a;
4ꂠb = "Br";

After running the preceding code, gold and a refer to the string "Au",
while b refers to "Br".

Class and Object


A class is the basic building block of code in object-oriented languages.
A class typically defines state and behavior. The following class is named
SmallClass:

1ꂠpackage com.example.mpme;
2ꂠpublic classꂠSmallClassꂠ{
3ꂠ}

Class names always begin with an uppercase letter in Java. It’s


common practice to use CamelCase to construct the names. This means
that instead of using spaces (or anything else) to separate words, we
uppercase the first letter of each word.
The first line is the package of the class. A package is like a directory on
the file system. In fact, in Java, the package must actually match the path
to the Java source file. So, the preceding class would be located in the path
com/example/mpme/ in the source file system. Packages help to organize
code and allow multiple classes to have the same name as long as they are
in different packages.
An object is an instance of a class in memory. Because a class can have
multiple values within it, an instance of a class will store those values.

11
Chap er 3 The Ba i捳

Create a Class

• Open your D (NetBeans).


• Note the common organizational structure of a typical
Java project in the file system:
• src/main/java: Java classes
• src/main/resources: Non-Java resources
• src/test/java: Java test classes
• src/test/resources: Non-Java test resources
• ight-click your Java project and choose New ➤
Java Class. Under “Class-Name” put “SmallClass”.
ut “com.example.mpme” for the package name.

Fields, Properties, and Methods


Next you might want to add some properties and methods to your class.
A field is a value associated with a particular value or object. A property is
essentially a field which has a “getter” or “setter” or both (a getter gets the
value and a setter sets the value of a property). A method is a block of code
on a class which can be called later on (it doesn’t do anything until called).

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捳

In the preceding code, name is a property, getName is a special method


called a getter, and print is a method which does not return anything (this
is what void means). Here, name is defined to be a String. System.out is
built into the JDK and links to “standard out” which we discuss later, and
println prints text and appends a newline to the output.
Methods can have parameters (values passed into the method), modify
fields of the class, and can have return values (a value returned by the
method) using the return statement. For example, modify the preceding
method, print, to the following:

1ꂠpublic String print(String value) {


2ꂠꂠname = "you gave me " + value;
3ꂠꂠSystem.out.println(name);
4ꂠꂠreturn name;
5ꂠ}

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:

1ꂠnew SmallClass().print("you gave me dragons")

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) }

Here name is a property and print is a method.

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ꂠclass SmallClass(var name:String) {


2ꂠꂠꂠdefꂠprint =ꂠprintln(name)
3ꂠ}

Creating a New Object


In all four languages, creating a new object uses the new keyword. 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:

1ꂠString gold = "Au"; // this is a comment


2ꂠString a = gold; // a is now "Au"
3ꂠString b = a; // b is nowꂠ"Au"
4ꂠb = "Br";
5ꂠ/* b is now "Br".
6ꂠꂠꂠthis is still a comment */

Those last two lines demonstrate multiline comments. So, in summary:

• Two forward slashes denote the start of a single-line


comment.

• Slash-asterisk marks the beginning of a multiline


comment.

• Asterisk-slash marks the end of a multiline comment.

Comments are the same in all languages covered in this book.

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

Technical form of apparitions: Elemental


Source of authenticity: First-hand evidence
Cause of hauntings: Unknown

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

Technical form of apparitions: Phantoms of the dead and possibly animal:


Elemental.
Cause of haunting: Murder
Source of authenticity: First-hand evidence

Should any one wonder why I continually select Northamptonshire


and Gloucestershire as the scenes of my ghost stories, let me hasten
to explain that my reason is obvious enough—with both these
counties I have had a lifelong intimacy and naturally have had more
facilities and opportunities for collecting suitable material from them
than from any other.
I have not the slightest doubt other counties can show equally
long lists of haunted houses, only I have not found them so easy of
access, moreover the genial nature of the inhabitants of
Northamptonshire (especially) has attracted as well as aided me in
my research, and although the burly Midland yeoman is inclined to
scoff at things superphysical, his satire is not so objectionable as is
that of the supercilious middle-class Londoner.
Again, Northamptonshire is very rich in well preserved old country
mansions—I know of no other county where there are so many—and
as most of these houses have at one time or another witnessed
some grim tragedy, it is not surprising that they are now the scenes
of occult manifestations.
Doubtless one would find similar phenomena in smaller
habitations were the latter of the same early date, for crime was
then just as prevalent among the poor as among the rich, but the
inferior material with which cottages have been built causes their
comparatively speaking early dissolution, and we rarely find a
cottage now standing which was built more than a century ago.
From this it must not be deduced that hauntings are confined to
old buildings nor that past crime alone begat ghosts; nothing of the
sort, modern villas are frequently subjected to psychic phenomena
whilst the phantoms of present-day suicides and murderers are
decidedly as numerous as of yore.
But whereas in olden times, crime was fairly common in villages, it
is now chiefly confined to towns, and the houses that have
witnessed murders, &c., are not infrequently entirely demolished or
made to undergo some very radical alterations—hence the ghosts
disappear with their surroundings.
This more so, perhaps, in the provinces than in London, as there
are too many crimes in the latter for any particular one to be
remembered for any length of time, not long enough in fact to
permanently damn the letting of a house.
The word ghost is very elastic, it may be used in reference to
many different types of spirits, and is, in fact, only the designation
for that genus of which the departed soul of man is but a species.
Now Northamptonshire is very rich in species; species of all kinds;
spirits of men, of beasts, of vegetables! and species of elementals—
elemental being in itself, a genus which includes many various types,
too numerous indeed, for any attempt at classification in this work.
It is no uncommon thing to meet with some locality (usually
barren) or village (generally on the site of barrows or Druidical
remains as, for example, Guilsborough) where the nature of the
hauntings is dual; a complexity that is, fortunately, of rarer
occurrence in houses.
Concerning the latter, Lee mentions one instance, i.e., “The Gybe
Farm,” in his book, “More Glimpses of the Unseen World” whilst I will
take this opportunity to quote another case of dual haunting, i.e.,
Carne House, which is situated at the utmost extremity of a village
to the south-east of Northampton.
My informant, Mrs. Norton, frequently resided in the house in her
childhood and youth, and it was from her lips that I heard the
following story which I recollect only too well.
* * * * *
My first impression of Carne House was one of extreme aversion; I
can see it now as I saw it then—vast, sleek, and white, like some
monstrous toadstool, or slimy fungus.
Bathed in the moonlight—for we did not arrive till late—it
confronted us with audacious nudity; not a plant or shrub being
trained to hide its naked sides. There was something unspeakably
loathsome in the boldness of its carriage—something that made me
glance with fear at its wide and gaping windows and glance again as
I crossed the threshold into the dark and lofty hall.
The passages of the house, both in number and sinuosity,
resembled a maze; they recalled to my youthful mind the story of
Dædalus, and I half expected to see the figure of the Minotaur
suddenly arise from some gloomy corner and pursue me through the
labyrinth.
Nor were my fears entirely groundless, for I had hardly been in
the place a month before I had a very unpleasant experience.
Chancing one morning to go on an errand for my mother to a
room that had in all probability once served as a laundry, but which
was now restricted to lumber, I was startled at hearing something
move either in or on the copper. Thinking it must be some stray
animal, or, may be, a rat, I threaded my way through a sea of
packing cases, and standing on tip-toe, peeped very cautiously into
the copper.
To my intense surprise I found myself looking into a very deep and
sepulchral well, at the bottom of which was a man. I could see him
distinctly, owing to a queer kind of light that seemed to emanate
from every part of his body. He was draped in a phantastic costume
that might have been a kimono or one of those flowery dressing-
gowns worn by our great-great-grandfathers. He was bending over a
box which he was doing his best to conceal under a pile of débris,
and it was undoubtedly this noise that had attracted me.
Too intent on his work, he was apparently unaware of my close
proximity, until, satisfied that the box was well hidden, he
straightened his back and looked up.
His face frightened me; not that it was anything out of the normal
either in feature or complexion, but it was the expression—the look
of evil joy that suffused every lineament before he saw me,
changing to one of the most diabolical fury as our eyes met. I was at
first too transfixed with terror to do more than stare, and it was only
when, crouching down, he took a sudden and deliberate spring at
the wall and began to climb it like a spider, that I regained
possession of my limbs, and turning round, fled for my life.
Oh! how long that room seemed and what an interminable
succession of furniture now appeared to barricade the way.
Every yard was a mile, every instant I expected he would clutch
me.
I reached the door only just in time—happily for me it was open—
I darted out, and as I did so the outlines of a hand—large and ill-
shapen—shot fruitlessly past me.
The next moment I was in the kitchen—the servants were there—I
was saved—saved from a fate that would assuredly have sent me
mad.
When I related what had happened, to my mother, she laughingly
informed me I must have been dreaming, that there was no well
there, nor was there any man in the house save my father and the
servants; yet I fancied I could detect beneath those smiling
assurances a faint and scarcely perceptible horror—and she never let
me visit that room again—alone!
But was I dreaming—was there no well, and had that man been
but the fancy of a childish and distorted brain?
Sometimes I answered “Yes,” and sometimes “No.”
After this little incident, a manifest, though of necessity, subtle
change took place in our household; the servants became infected
with a general spirit of uneasiness, which although only shown in my
presence by their looks, convinced and alarmed me far more than
any fears, even the most terrible, would have done had they been
outspoken. I was positive they lived in daily anticipation of
something very dreadful—something that lay concealed in those
dark and tortuous corridors or in that grim and ghostly room.
My dreams at night were horrible, nor did I again feel that in this
respect I was singular as I overheard some one remark that no one
ever passed the night without awakening with a sudden and
inexplicable start.
I say inexplicable—would that it had always remained so!
It was August when my next definite adventure occurred. I use
the word definite as I had had several other experiences, but of too
brief and uncertain a nature to enable me to draw any precise
conclusions.
Once, as I had been walking along one of the passages, I had
heard the noise of something clanking, and had been put to instant
flight by the sound of heavy footsteps echoing suddenly in my rear,
and again—but this isn’t really worth recording; let me proceed with
that night in August.
Well, I slept in a room at the end of a corridor, my nearest
neighbour, Miss Dovecot our governess, occupying a chamber some
dozen yards away. I do not think I need describe any article of
furniture the room contained; every piece was strictly modern, and
had been brought with us from a newly furnished house in
Sevenoaks. The fireplace and cupboard are, however, deserving of
comment; the former was one of those old-fashioned ingles Burns
delights in describing, and which are now so seldom to be seen; an
inn at Dundry, near Bristol, containing, I believe, the finest specimen
in the kingdom; whilst the latter, which I always kept securely locked
at night, was of such far-reaching dimensions that it might well be
termed in modern phraseology a linen room.
On the night in question, I had gone to bed at my usual time—
eight—and I had speedily fallen to sleep, as I was in the habit of
doing; but my slumber was by no means normal.
I was tortured with a series of disturbing dreams, from which I
awoke with a start to hear some clock outside sonorously strike
twelve. As an additional proof of my wakefulness, I might add
(pardon my explicitness) I was sensibly affected by a constant
irritation of the skin, due, I believe, to a disordered state of the liver,
which in itself was a sufficient preventive to further sleep.
It must have been half-past twelve when I heard, to my intense
horror, the cupboard door—which I distinctly recollect locking—
slowly, very slowly, open.
My first impulse was to make a precipitate rush for the door, but,
alas! I soon became aware that I was powerless to act; a kind of
catalepsy, coming on suddenly, held my body as in a vice, whilst my
senses, on the other hand, had grown abnormally acute.
In this odious condition I was now compelled to listen to the Thing
—whatever it might be—slowly crossing the floor in the direction of
my bed.
The climax at length came, and my cup of horrors overflowed,
when, with an abruptness that was quite unexpected (in spite of the
direst apprehension), the Thing leaped on the bed, and I discovered
it to be an enormous cat.
I can unhesitatingly add the epithet—Black—for the room, which a
moment before was shrouded in darkness, had now become a blaze
of light, enabling me to perceive the colour as well as the outline
with the most unpleasant perspicuity.
It was not only in intensity of colour (the blackest ebony could not
have been blacker) that the cat was abnormal, but in every other
respect; its dimensions were not far removed from those of a large
bull-dog, and its expression—the eyes and mouth of the beast were
more than bestial—was truly Satanic. Stalking over my legs, its tail
almost perpendicular and swaying slightly like the nodding plumes of
a hearse, it squatted down between the bedposts opposite,
transfixing me with a stare full of malevolent meaning.
I was so fully occupied in watching it and trying to solve the
enigma I saw so plainly written in its every gesture, that I did not
realise I had other visitors, till a sudden uncertain twitching in the
light made me look round. I then perceived with a start a fire was
burning in the grate.
A fire, and in August—how incongruous! I shivered.
But it was no delusion; the flames soared aloft, adopting a
hundred fantastic yet natural shapes; the coals burned hollow, and
in their crimson and innermost recesses I read the future.
But not for long. My cogitations were unceremoniously interrupted
by the appearance of the man-in-the-well, whom I was startled to
perceive seated in the chimney-corner in the most nonchalant
attitude possible—nursing a baby!
Anomalous and mirth-provoking as is such a sight in the usual
way, the existing circumstances were grim enough to excite my
horror and raise anew my worst forebodings.
Supposing he saw me now? There was no escape! I was entirely
at his mercy. What would he do?
I glanced from him to the cat, and from the cat back again to him.
Of my two enemies, which was most to be feared? The slightest
movement on my part would inevitably arouse them both, and bring
about my immediate destruction. The situation did not even warrant
my breathing.
The minutes sped by with the most tantalising slowness. The clock
struck one, and neither of my visitors had budged an inch—the man
in the flowery dressing-gown still nursing the baby, and the black cat
still staring at me. Mine was indeed a most unenviable position, and
I was despairing of its ever being otherwise, when a sudden
transmutation in the man sent a flow of icy blood to my heart.
He no longer regarded his burden indifferently—he scowled at it.
The scowl deepened, the utmost fury pervaded his features,
converting them into those of a demon. He got up, gnashed his
teeth, stamped on the ground, and lifting up the child, dropped it
head first into the fire. I saw it fall. I heard it burn!
The hideous cruelty of the man, the abruptness of his action,
proved my undoing. Oblivious of personal danger, I shrieked.
The effect was electrical. Dropping the poker, with which he had
been holding down the baby, the inhuman monster swung round
and saw me.
The expression in his face at once became hellish, absolutely
hellish.
My only chance of salvation now lay in making the greatest noise
possible, and I had commenced to shout for help lustily, when at a
signal from the man, the enormous black cat crouched and sprang.
What followed I cannot exactly remember, I have dim recollections
of feeling a heavy thud and of some one or some thing trying to tear
away the clothes from my head, after which there came a very
complete blank, and when I recovered consciousness, the anxious
countenances of my parents and governess were bending over me.
The next night I slept with my sister.
My health had been so impaired by these encounters, that my
parents decided to move elsewhere; the furniture was once again
packed, and within a month of the above incident we had taken up
our abode in Clifton, Bristol.
The history of the hauntings was subsequently revealed to me by
the owner of the house. It had once been inhabited by a man of the
name of Darby, who seems to have been a sort of wholesale
butcher.
His elder brother dying, the family estate passed to the latter’s
eldest son, a child of two, and Darby determining to succeed to the
property, invited the widow to stay with him. She did so—she was a
weakly creature—and he got rid of her by putting her to sleep in a
damp bed. The children were next disposed of, the younger by being
burnt (as I had witnessed) and the elder, aged two, by being
smothered to death by a black cat. Darby is said to have deliberately
made the cat sit upon the infant’s mouth as it lay asleep. But these
rapid deaths, as might have been expected, aroused suspicions. The
nurse, who had been an unwilling party to the burning of the baby,
turned King’s Evidence, and a warrant for his arrest was issued. As is
often the case, however, the officers of the law were a bit too late.
When they arrived at the house, the quarry had flown, nor could his
whereabouts be discovered for many years; not, indeed, till fifty
years after the crimes, when his skeleton was found at the bottom of
a disused well he had himself sunk in one of the back kitchens.
Under the skeleton lay an iron box containing many valuables, rings,
&c., which he had been doubtless striving to hide when death in
some unaccountable form or another overtook him. What became of
the cat, history does not say.
The place had always borne a reputation for being haunted—it
was on that account my parents had got it at so low a rental—and
the ghosts seen there (undoubtedly those of Darby and his cat)
corresponded in every detail with the phenomena that had so
terrified me.
I am aware that many deny the existence of souls in animals—let
them do so—but do not let them be too dogmatical, for where Life
ends all is mystery.
Still there is an alternative theory to account for the appearance of
animal phantoms, which is, I think, quite within the realms of
possibility: the black cat I saw, if not the spirit of the one made such
hideous use of by the old man, was undoubtedly an elemental—a
spirit representative of a popular crime, a vice—Darby’s evil genius—
that ever hovered at his heels in his lifetime and is more loth than
ever to leave him now that his physical body is dead and his soul
earthbound.
HARLEY HOUSE, PORTISHEAD
THE BLACK ANTENNÆ

Technical form of apparitions: Poltergeists (or Elementals)


Source of authenticity: First-hand evidence
Cause of hauntings: Unknown

The following account of a haunted house is taken from the diary of


a gentleman—since deceased. The narrator was the owner of the
house, and, being a professional man, asked me to give fictitious
names, lest the publication of the story should be detrimental both
to his practice and to the letting of the place:
“Before I commence my story,” he writes, “I think it expedient to
state that both my parents are dead, my father having died many
years ago and my mother quite recently. The latter had lived to the
very ripe age of ninety, had possessed an unusually strong will, was
a most devout Roman Catholic, and took the deepest interest in
everything that concerned our welfare. She had two peculiarities: (1)
A strange aversion to children; (2) a positive loathing and dread of
blackbeetles. The house stands alone, some thirty yards or so from
the road, and is well concealed from view by a high brick wall and
numerous trees.
“There are four bedrooms upstairs, two on either side of the
landing—which for clearness I will number—viz., No. 1 occupied by
my wife and I; No. 2 my sister Mary’s room; No. 3 my sister Joan’s
room; No. 4 the spare bedroom in which my mother died. The top
storey consists of two attics inhabited by the servants.
“January 1, 1906, we first became aware of the disturbances—
violent knockings being heard about midnight on the walls and floor
of room No. 4. On hurriedly entering it, we could discover nothing.
But on leaving the room the noises were repeated and kept up till
two or three in the morning.
“January 5. A recurrence of the disturbance—only much louder.
“January 6. Have in a carpenter who makes a thorough
examination of the wainscoting and reports ‘no traces of rats, mice
nor any other animals.’
“January 10. Tremendous knockings again in room No. 4, the door
of which is swinging to and fro violently. A loud clatter on landing as
though half a dozen children were engaged in the roughest horse-
play. The uproar terminates in a terrific crash on the panel of No. 3
door. Joan rushes out of her bedroom thinking the house is on fire
and sees a strange, green light some six by two feet long moving
across the landing. It disappears in room No. 4.
“January 15. We are all awakened by a loud crash and on reaching
the landing find a big, black oak chest from the coach-house, lying
there on its back. Every one much alarmed.
“February 1. My sister Mary awakened at midnight by feeling
something tickle her cheeks. She puts out her hand to brush it away
and encounters something cold and scaly. Her shrieks of terror bring
us all into her bedroom—there is nothing there.
“February 3. My wife and I are aroused by feeling our bed gently
lifted up and down, and on my getting out for a light, I tread on
something indescribably disgusting. It feels like a monstrous insect!!
“February 4. The knocking very bad all night—particularly in room
No. 4.
“February 5, 6, 7, ditto.
“February 10. The clothes mysteriously taken off Joan’s bed and
transported to room No. 2.
“February 15. Both servants undergo our experience of February
3.
“February 16. The knockings still continued and distant sounds
heard as of some one coming upstairs and turning the handles of all
the room doors.
“February 17. Scufflings on the landings, and in the passage as
though caused by a troop of very noisy children.
“February 19. Knockings in room No. 2. The washstand and a
heavy mahogany wardrobe moved some feet out of their places.
Mary, who was awake at the time, saw the shunting of the furniture,
but could detect no sign of any agent.
“March 1. About 8.30 a.m. after Martha had laid the breakfast
things she went downstairs to finish a cup of tea. On her return to
the breakfast room she found it in the wildest state of disorder;
chairs over-turned, ashpan and front of grate removed to furthest
extremity of room, all the pictures taken down from the walls and
laid face upwards on the floor, and the cups, saucers, plates, knives
and forks piled in one heap in centre of table; all this had been done
without either breakage or noise.
“Terrified out of her wits Martha rushed upstairs to our door, and
nothing would induce her to enter the breakfast room again alone.
“March 3. On returning home about 10 p.m. from a neighbouring
town, we found the servants sitting huddled together, half dead with
fright in the kitchen. They had heard knockings and the most
appalling thuds ever since we had gone out; and on entering our
room (No. 1) we found it in an absolute turmoil: the bed-clothes in a
promiscuous pile on the floor, the duchess table turned round with
its face to the wall, the pictures ditto—but—nothing broken.
“March 15. Awakened in middle of night by three loud crashes in
room No. 3, after which we distinctly heard our door open and some
one crawl stealthily under our bed.
“We at once lit a candle—no one was there.
“March 18. Knockings in both the attics. The servants badly
scared.
“March 21. As Joan was running downstairs about mid-day, she
received a violent bang on her back as if some one had hit her with
the palm of their hand. She came to my study in a very exhausted
condition, and it took her some minutes to recover.
“March 24. Found my mother’s shoes, which we were certain had
been locked up in a bureau, placed where she had always placed
them in her lifetime—i.e., on the hearth-rug before the dining-room
fire.
“March 31. My mother’s favourite arm-chair found upside down in
front of the fire-place in room No. 4.
“April 2, 11 p.m. As Mary was stooping to look under the bed for
fear of burglars, she was suddenly pushed down and the mattresses
and bedclothes were thrown on the top of her. Her frantic struggles
and muffled screams being, fortunately, overheard by my wife (I was
in London at the time), she was immediately extricated. No injury,
only bad shock.
“April 3, midnight. The contents of a large chest of drawers in
room No. 3 suddenly emptied on to the floor. Loud crashes in all
parts of the house.
“April 10, 11 p.m. On going up to bed, we find room No. 4 aglow
with a pale green light and filled with a faint sickly odour, which we
at once recognised as identical with that smelt there at the time of
my mother’s decease and which we considered was peculiar to her
disease.
“I must mention that after her death, the room had been
thoroughly renovated, the old flooring replaced by new, the walls
repapered and everywhere well disinfected with the strongest
carbolic. My mother had died at 11 P.M.
“April 12, 13, 14, 15; 11 p.m. The same light and smell.
“April 20. Joan fell over some large obstacle in the hall, hurting
herself badly. She could see nothing, but was half suffocated with a
stench similar to the one already described.
“April 30, 2.20 a.m. Both my wife and I distinctly felt something
brush across our faces. We lit a candle and perceived to our horror
two long black antennæ (like the antennæ of a monstrous beetle)
waving to and fro on our pillow.
“We spent the rest of the night on the drawing-room chairs and
sofa.
“May 1. Shut up the house.”
Note.—An attempt to solve the mystery surrounding these hauntings will appear
in a subsequent volume.
THE WAY MEADOW, SOMERSET
THE INVISIBLE HORROR

Technical form of haunting: Unknown


Source of authenticity: Personal and other experiences
Cause of haunting: Unknown

In my boyhood days I was very fond of making long excursions on


foot, my peregrinations taking me many miles from Bristol, which
was at that time my home. On one of these occasions I took a route
that led me past Bath, and eventually arrived at a village that
particularly fascinated me.
Lying in a hollow by the side of a sluggish river, or stream, it
presented an exceedingly attractive appearance to my somewhat
romantic eyes. I especially liked the whitewashed cottages, with
their thatched roofs, diamond-fashioned window-panes, walls and
trellised arches covered with jasmine and Virginian creepers; their
tiny gardens crowded with foxgloves and roses, and their quaint,
their very quaint chimney-pots, from which arose spiral columns of
fleecy-looking smoke.
It was a pretty village, a pre-eminently peaceful village; a village
that was rendered almost fantastic by the close proximity of a
queerly constructed water-mill; it was a sunny village, remarkably
hot in summer, but intensely cold in winter.
The stream to which I have alluded ran its tortuous course
through a succession of open meadows. In the corner of one was a
pond, a deep and silent piece of water that was supposed to be
connected in some way with the miniature river. It struck me as a
very proper place for a bathe, the weeping willows that fringed its
margins affording an effectual screen to the prying eyes of children;
whilst the gently sloping banks of spongy grass were softer to the
tread than any towel.
To add to my inducements the sun was unusually hot, which made
the thought of a bath very tempting after my long tramp over dry
monotonous roads.
Plunging in, I was, however, immeasurably surprised to find that,
despite the abnormal heat, the water was icy cold, and that the
scalding rays from above did not appear to have the slightest effect
on the temperature.
Taking a few rapid strokes, I found myself nearing the opposite
bank, and was preparing to turn about when a sudden panic seized
me, and, fancying I was being pursued, I scrambled ashore.
Seeing nothing, and consequently assured that my fears were due
to the trickeries of imagination, I once again entered the water and
was well on my return voyage when I experienced the same
sensation. I seemed to feel the presence of some extremely hostile
and repulsive body—something that lived in the pool and bitterly
resented intrusion. So strong was this feeling that I would not on
any account have bathed there again—at least, not alone.
In response to my inquiries in the village, I learned that the
meadow, which went by the name of “The Way,” bore a very evil
reputation, being carefully avoided by the local people after nightfall.
Though nothing had been actually seen there, those who had
attempted to cross the field in the dusk emphatically declared they
were assailed by an “invisible something” that was indescribably cold
and horrid, and that they only escaped from it after the most
strenuous exertions.
Nothing short of force would induce a dog or a horse to enter the
meadow, and farmers fought shy of letting their cattle graze there;
indeed, should any farmer be so foolish as to do so his beasts
invariably died.
I suppose I looked a trifle sceptical at this, as the blacksmith
remarked: “Don’t smile, sir; if you saw Way Field, and especially the
pool, after twilight, you would form a very different idea of it to what
you do now. In the day-time it is, as you see, all sunlight and
daisies, an ideal spot for tea in the hay; but in the evening the
aspect undergoes a complete change. The temperature is invariably
lower there than it is in any of the other meadows, whilst the
shadows that crowd upon the grass are not in the least
representative of any trees! Curious, sir, is it not?”
I readily agreed it was curious, and I was so deeply impressed by
all that had occurred that, years afterwards, when chance once
again brought me in the district, I lost no time in setting off to visit
the pond.
To my astonishment it was gone, and its site was now occupied by
the kitchen garden of a large house, evidently the abode of some
person of means.
I made inquiries and had but little difficulty in obtaining an
introduction to the owner who was not only acquainted with what I
already knew, but was able and willing to give me further
information, with the stipulation, however, that on no account must I
mention either his name or that of the locality. He wanted, he
explained, to sell the place and he could not hope to get a fair price
for it, if the story of the hauntings appeared in print.
“I have been here three years!” he began, “during which time I
have had no less than eight housekeepers and twenty-five servants
(my usual staff consists of four); that signifies a good few changes.
Eh?”
“Yes, it has been a confounded nuisance!” he went on, “none of
them would stay on account of the ghost! I pooh-poohed the thing
at first, although I honestly felt there was something very queer
about the place, but when one after another came to me with the
same yarns, I was obliged to admit there might be something in it.
“Their complaints, though differing slightly in small technicalities—
due, perhaps, to their unequal descriptive powers—were on the
whole co-incidental; frightful dreams, sudden awakenings without
any apparent cause, strange creakings on the staircases, the foot-
falls of something soft and indefinable, the rattling and turning of
door handles, and over and above everything else the most
pronounced feeling of insecurity.
“‘I won’t on any account remain downstairs after the rest have
gone to bed,’ one of my housekeepers observed on my asking her to
sit up for me, ‘the very first night I stayed here—before I had heard
any rumour of the place being haunted—I underwent the most
unpleasant sensations on being left alone. I instinctively felt some
uncanny creature had begun to walk the house as soon as the lights
were out. No, sir. I am ready and anxious to fulfil all my other duties,
save this, and if it is really indispensable, why I fear, sir, you must
get someone else in my place.’
“This I promptly did, but all to no effect. The newcomer had not
been with me a week before she approached me with a very woe-
begone face.
“‘I am sorry, sir,’ she said, ‘I must give notice. I am by no means
nervous, indeed I have always laughed at ghosts, but there is
something unmistakably the matter with this place, especially the
garden!’
“‘The garden!’ I exclaimed, ‘Come, it’s the first time I have heard
there’s anything amiss with the garden.’
“‘But not the last, I’ll warrant you,’ she remarked caustically. ‘Why
sir, unless I am very much mistaken, the origin of the disturbances
lies in that garden, over there,’ and she shot a bony forefinger (why
should housekeepers invariably have bony fingers?) in the direction
of the filled-in pond. ‘As I was gathering some lettuce there last
night I felt (I could see nothing) some horribly cold and sticky thing
clasp me in its arms. It must have been hiding among the raspberry
canes. Struggling with all my might I managed to free myself just as
a mass of fetid jelly was closing over my throat and mouth. Oh! how
desperately I struggled, and what a blessed relief it was to be free
from that loathsome presence. I can assure you, sir, I ran across the
garden as fast as any girl, nor did I pause for one second, till
Johnson and one of the maids came to my assistance. They did not
ask me what had happened, bless you sir, they knew! Nor was a
word said about it at supper, no one dare even as much as mention
the thing by gaslight!’
“It was useless, Mr. O’Donnell, to try and persuade the woman to
remain with me after that, she went and, by the bye, I have just
heard she has recently undergone an operation for tumour in some
provincial hospital.
“With my next housekeeper I was rather more fortunate. She
stayed with me for more than six months before showing any of the
usual signs of restlessness.
“Then she came to the point without the least embarrassment,
springing her surprise on me over the breakfast cups.
“‘I must leave!’ she said demurely, proceeding at the same time to
pour out the coffee, ‘there is a certain dampness here that is very
trying to one subject to rheumatism, as well as to one’s nerves.’
“I started guiltily. ‘A dampness! Nerves! you astonish me,’ I
stammered, ‘pray explain yourself.’ She did so.
“‘What I mean is,’ she observed, ‘that I can never enter the lower
part of the kitchen garden without being persistently followed by a
“mist”—I should have put it down to mere imagination, had I not
accidentally heard some one speak about the ghost, and I at once
concluded that the mist must in some way be connected with it—am
I not right?’
“Of course I assented—what else could I do?
“‘I thought so,’ she went on demurely, ‘I suppose you do not think
it necessary to tell your applicants the place is haunted?’
“I shook my head feebly and muttered: ‘Continue.’
“‘Last night,’ she said, ‘the mist was more pertinacious than ever—
it not only pursued me in the garden, but came to my window after I
had gone to bed. I was looking at the moon when the temperature
of the room suddenly fell to zero, the moonlight blurred, and to my
amazement I saw the mist clinging to the window-pane. Mr. ——, I
am not a nervous woman as a rule, but I wouldn’t stay in this house
another month under any conditions.’
“She went—and once again I had to go through all the bother of
advertising. The wretched thing now began to haunt more
vigorously than ever. It attacked Emily, the cook, on the kitchen
staircase, and Mark, my general factotum, in the stables, both
leaving in consequence, and both being afterwards taken very ill.
Indeed it was the report of their illness that prompted me to wage
war against the ghost—if I had to leave the house, it should not be
till I had ascertained something more definite about my enemy. I
would try and discover its identity—what it actually was! With this
end in view I laid every trap imaginable, my ingenuity being at
length rewarded by finding a faint and barely perceptible impression
on the surface of a very large tray full of a carefully prepared
mixture of gelatine and wax. I had placed the tray in one of the
passages usually frequented by the evil presence. On examining the
impression under a powerful microscope I fancied I could detect
innumerable granules composed of radiating threads with bulbous
terminations.
“Elated at my success and wondering very much what it
represented, I took a photograph of the impression and sent it to a
medical friend—a bacteriologist—in London, whom I knew to be
interested in psychical research. In the course of a few days he
came to see me, and, pointing to the wax tablet, remarked:
“‘I showed the photograph you sent me to some of my colleagues,
and we came to the conclusion that the impression bore a distinct
likeness to a number of actinomyces, which, as you may know, are a
kind of fungi inimically disposed to every kind of animal—cattle in
particular. Indeed they are in the main responsible for one of the
most common and deadly bovine diseases which is called
actinomycosis, and is acquired by cattle eating infected barley or
other cereal, the actinomyces adhering to the tongue or jaw.
“‘In man the disease is very similar in its clinical character and
may be caused by a number of organisms belonging to the
streptothrix group (I fear this is rather too technical for you) forming
colonies in the tissues and obtaining access to the body from a
carious tooth or not infrequently from the tonsil.
“‘The disease is sometimes wrongfully diagnosed as tuberculosis;
it usually occurs in farmers, millers, and others who are brought in
contact with grain; it has a tendency to spread locally, and although
not dangerous in itself, may become so by attacking important
organs or by becoming generalised, thereby giving rise to pyæmic
abscesses in all parts of the body.
“‘In the description of the assault on your housekeeper, to which
you gave special prominence (and rightly so) in your letter, you
mentioned that the evil presence tried to “get at her mouth”—well
that would be in strict accordance with the modus operandi of
actinomyces, the primary endeavour of which is to obtain a passage
through the lips. Furthermore, you gathered from local gossip that
the unfortunate woman had undergone an operation in some
provincial hospital for tumours; now tumours are usually one of the
sure indications of the nature and progress of the disease.
“‘Lastly, you referred to fatality in any cattle allowed to graze in
the haunted meadow. Now you know from what I have already told
you that cattle are the favourite victims of the fungi.
“‘From these deductions then, one must inevitably arrive at the
conclusion—that the haunting here is due to nothing more or less
than the phantasm of a giant mass of actinomyces—and as this type
of spirit would undoubtedly be proof against exorcism my only
advice to you is to shut up the house and go.’
“Afterwards, with a view to corroborate my friend’s theory, partly
for his satisfaction, partly for my own, I am afraid, Mr. O’Donnell, I
agreed to rather a cruel thing—the proposal being that we should
experiment on one of our dogs—Spot. Turning him loose in the
lower extremity of the garden, we took up a position in the loft of a
neighbouring barn, where we clearly saw each act in the grim but
exciting drama.
“To begin with, Spot did not at all appreciate being left alone.
From the very first he manifested distinct signs of uneasiness, his
preliminary barks of disapproval speedily changing to those of fear
and culminating in howls of positive terror, as tucking his tail
between his legs, he careered madly round the enclosure.
“He did not, however, keep up this pace for long, but soon showed
unmistakable signs of flagging, coming to an abrupt halt sooner than
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!

textbookfull.com

You might also like