Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Full Download Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript 2nd Edition Adam L. Davis PDF DOCX

JavaScript

Uploaded by

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

Full Download Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript 2nd Edition Adam L. Davis PDF DOCX

JavaScript

Uploaded by

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

Experience Seamless Full Ebook Downloads for Every Genre 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 BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

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/

textboxfull.com

Biota Grow 2C gather 2C cook Loucas

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

textboxfull.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/
textboxfull.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/
textboxfull.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/
textboxfull.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/

textboxfull.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/
textboxfull.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/
textboxfull.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/

textboxfull.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 editorial@apress.com; for reprint, paperback, or
audio rights, please email bookpermissions@springernature.com.
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 Scribd Document
with Unrelated Content
The Project Gutenberg eBook of A lady in black
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: A lady in black

Author: Florence Warden

Release date: December 4, 2023 [eBook #72314]

Language: English

Original publication: New York: The International News Company,


1895

Credits: an anonymous Project Gutenberg volunteer

*** START OF THE PROJECT GUTENBERG EBOOK A LADY IN


BLACK ***
A LADY IN BLACK
BY
FLORENCE WARDEN
Author of “The House on the Marsh,” “A Terrible Family,”
“Adela’s Ordeal,” “A Perfect Fool,” “A Sensational
Case,” etc.

THE TRADE SUPPLIED BY


THE INTERNATIONAL NEWS COMPANY,
LONDON. NEW YORK. LEIPSIC.
[COPYRIGHT.]
Copyright, 1895,
by
The International News Company.
[All Rights Reserved.]
CONTENTS.
I.—A Mystery Somewhere
II.—A Penitent
III.—An Invitation and a Warning
IV.—Was It a Recognition?
V.—A Startling Visit
VI.—Mr. Banks
VII.—A Strange Fancy
VIII.—A Haunted House
IX.—A Picture
X.—The Picking Up of Some Silver Threads
XI.—An Interview with Mr. Banks
XII.—A Horrible Secret
XIII.—Mrs. Dale’s Version of the Story
XIV.—No Mercy
XV.—Some Explanations
A LADY IN BLACK.

CHAPTER I.
A MYSTERY SOMEWHERE.

“And besides, you know, my dear Mrs. Rose, there is generally


something wrong about a woman who dresses so very well.”
So spoke Mrs. Bonnington, the Vicar’s wife, laying down the law; a
law indeed, which most English women are ready to take for
granted. Mrs. Rose, a tall, thin, pale lady who had “nerves,” and who,
on this bright April morning, wore a woollen shawl half off her
shoulders as she sat in the warm sun by the dining-room window,
assented readily.
“That’s what I always say. Especially a widow. I’m sure if anything
were to happen to my husband,” went on Mrs. Rose euphemistically,
“the last thing I should think about would be my dress. I should be far
too unhappy to trouble myself about the fit of my dresses or the
shape of my bonnets.”
Now this was perhaps true, as Mrs. Rose, though she spent as
much money and as much thought upon her clothes as her
compeers, never succeeded in looking as if her clothes had been
made for her, or as if the subject of “fit” were of any importance.
Mrs. Bonnington shook her head with vague disquietude, and
resumed her homily.
“I assure you the matter has caused me a good deal of anxiety.
You know how solicitous both the Vicar and I are about the tone of
the parish.”
“I do indeed,” murmured Mrs. Rose sympathetically.
“You know how hard we work to keep up a high standard. Why,
everybody knows that it was through us that those objectionable
people at Colwyn Lodge went away, and how we would do anything
to rid the place of those terrible Solomons at Stone Court!”
At the other end of the room, a young face, with gray eyes full of
mischief, was turned in the direction of Mrs. Bonnington with a
satirical smile. Mabin Rose, the overgrown, awkward step-daughter
of Mrs. Rose, who hated the Vicar’s wife, and called her a busybody
and a gossip, brought her darning nearer to the table and dashed
headlong into the fray.
“Papa wouldn’t thank you if you did drive the Solomons out of the
parish, as you did the people at Colwyn Lodge, Mrs. Bonnington,”
broke in the clear young voice that would be heard. “He says Mr.
Solomon is the best tenant he ever had, and that he wishes that
some of the Christians were like him.”
“Hush, Mabin. Go on with your work, and don’t interrupt with your
rude remarks,” said Mrs. Rose sharply. “I am quite sure your father
never said such a thing, except perhaps in fun,” she went on, turning
apologetically to her visitor. “Nobody is more anxious about ‘tone’
and all those things than Mr. Rose, and he was saying only
yesterday that he would rather I didn’t call upon this Mrs. Dale until
something more was known about her.”
Again the young face at the other end of the table looked up
mutinously; but this time Mabin controlled her inclination to protest.
She looked down again, and began to darn furiously, to the relief of
her feelings, but to the injury of the stocking.
Mrs. Bonnington went on:
“You were quite right. It’s not that I wish to be uncharitable.”
“Of course not,” assented Mrs. Rose with fervor.
“But a woman like yourself, with daughters to take care of, cannot
be too careful. Young people are so easily led away; they think so
much of the mere outside. They are so easily dazzled and taken in
by appearances.”
Mabin grew red, perceiving that this little sermon by the way was
directed at herself. Her step-sisters, Emily and Ethel, one of whom
could be heard “practising” in the drawing-room, were not the sort of
girls to be led away by anything.
“But why shouldn’t a nice face mean something nice?” put in the
rash young woman again.
The fact was that Mabin had been charmed with the sweet pink-
and-white face and blue eyes of Mrs. Dale, their new neighbor at
“The Towers,” and was mentally comparing the widow’s childlike
charms with the acidulated attractions of the Vicar’s dowdy wife.
“And why,” pursued Mabin, as both the elder ladies seemed to
pause to gain strength to fall upon her together, “shouldn’t she be
just as sorry for her husband’s death because she looks nice over it?
It seemed to me, when she sat near us at church on Sunday, that
she had the saddest face I had ever seen. And as for her corrupting
us by her ‘tone,’ she won’t have anything to do with any of us. Mrs.
Warren has called upon her, and the Miss Bradleys and Mrs. Peak
and a lot more people, and she’s always ‘not at home.’ So even if
she is wicked, I should think you might let her stay. Surely she can’t
do us much harm just by having her frocks better made than the rest
of us.”
When Mabin had finished this outrageous speech, there was an
awful pause. Mrs. Rose hardly knew how to administer such a
reproof as should be sufficiently scathing; while Mrs. Bonnington
waited in solemn silence for the reproof to come. Mabin looked from
her step-mother’s face to that of the Vicar’s wife, and thought she
had better retire before the avalanche descended. So she gathered
up her work hastily, running her darning-needle into her hand in her
excitement, muttered an awkward apology and excuse for her
disappearance at the same time, and shot out of the room in the
ungainly way which had so often before caused her stepmother to
shudder, as she did now.
When the door had closed upon the girl, closed, unfortunately, with
a bang, Mrs. Bonnington sighed.
“I am afraid,” she said, unconsciously assuming still more of her
usual clerical tone and accent, “that Mabin must be a great anxiety to
you!”
Mrs. Rose sighed and closed her eyes for a moment, wearily.
“If you could realize how great an anxiety,” she murmured in a
solemn tone, “you would pity me! If it were not that Mr. Rose gives
his authority to support mine in dealing with her, she would be
absolutely unmanageable, I assure you.”
“A froward spirit! And one singularly unsusceptible to good
influences,” said the Vicar’s wife. “However, we must persevere with
her, and hope for a future blessing on our labors, even if it should
come too late for us to be witnesses of her regeneration.”
“I am sure I have always done my best for her, and treated her just
as I have my own children. But you see with what different results!
The seed is the same, but the soil is not. I don’t know whether you
knew her mother? But I suppose Mabin must take after her. She is
utterly unlike her father.”
“She is indeed. Mr. Rose is such a particularly judicious, upright
man. The Vicar has the highest respect for him.”
Mrs. Bonnington paused, to give full effect to this noble encomium.
Mrs. Rose acknowledged it by a graceful bend of the head, and went
on:
“The great failing about poor Mabin is that she is not womanly.
And that is the one thing above all that my husband asks of a
woman. Let her only be womanly, he always says, and I will forgive
everything else. Now my own girls are that, above everything.”
“Ah!” exclaimed Mrs. Bonnington with decision; “but that is just the
fault of our age, Mrs. Rose. Girls are no longer brought up to be
contented to be girls. They must put themselves on the same footing
with their brothers. Mabin is in the fashion. And no doubt that is all
she desires. You see how this Mrs. Dale has caught hold of her
imagination, by nothing but her fashionable clothes!”
Mrs. Rose put on a womanly air of absolute helplessness:
“Well, what can I do?” said she.
Mrs. Bonnington came a little nearer.
“In the case of this Mrs. Dale,” said she in a lower voice, “go on
just as you have begun. Do not call upon her. Do not have anything
to do with her. To tell you the truth, it was about her that I came to
see you this morning. She has already brought mischief into our own
peaceful home. She is a dangerous woman.”
“Dear me! You don’t mean that!” said Mrs. Rose with vivid interest.
“Unhappily I do. My son Rudolph came back from his ship only ten
days ago, and already he can think of nothing but this Mrs. Dale.”
“After having had the unpardonable insolence to leave your call
unreturned, she has got hold of your son?” gasped Mrs. Rose.
“Well, not exactly that, as far as I know,” admitted the Vicar’s wife.
“He says he has never spoken to her. And the dear boy has never
told me an untruth before.”
“But if this dreadful woman has entangled him, of course she
might make him say anything!” cried Mrs. Rose in sympathetic
agonies.
“I should not like to accuse a fellow-woman of doing that,” replied
Mrs. Bonnington, severely; “but I think it is a bad and unnatural sign,
when my son, who has never taken the least notice of any of the
young girls in the neighborhood, becomes absorbed, in a few days,
in the doings of a person who is a complete stranger to him and who
calls herself a widow.”
“Then don’t you think,” purred Mrs. Rose, with the eagerness of
one who scents a scandal, “that she is a widow?”
There was a pause. And Mrs. Bonnington spoke next, with the
deliberation of one who has a great duty to perform.
“I should be very sorry to have it said of me that I was the first to
start a rumor which might be thought unchristian or unkind,” she said
with a deprecatory wave of the brown cotton gloves she wore in the
mornings. “But I have thought it my duty to make inquiries, and I
deeply regret to say that I have found out several things which lead
me to the conclusion that this person has settled down in our midst
under false pretences.”
“You don’t say so!”
“You shall judge for yourself. In the first place, although she calls
herself Mrs. Dale, the initials on some of her linen are ‘D. M.’ Now M.
does not stand for ‘Dale,’ does it?”
“Perhaps her maiden name began with M.,” suggested Mrs. Rose.
“My informant tells me,” went on Mrs. Bonnington, as if offended
by the interruption, “that in her old books, school-books and work of
that sort, there is written the name ‘Dorothy Leatham.’ So that she
seems to have passed already by three different names. I leave it to
your own common sense whether that is not a curious circumstance,
considering that she is still young.”
“It is certainly curious, very curious. And—and—”
Mrs. Rose hardly liked to ask on what authority her visitor made
these statements, which savored strongly of the back-stairs. She had
hardly paused an instant before Mrs. Bonnington rushed into further
details:
“And now here is another thing which is very strange: her servants
have none of them been with her long. They were all engaged
together, three months ago in London, not by Mrs. Dale herself, but
by an old lady whose name nobody seems to know. Now isn’t that
rather remarkable? They all came down here, and had the place
ready for their mistress, before they so much as saw her.”
Mrs. Bonnington leaned back in her chair, and drew on her brown
cotton gloves further. Mrs. Rose wondered again as to the source of
this information. She felt a little ashamed of listening to all this
gossip, and was less inclined than her friend to take a suspicious
view of the case, strange though it was. So she contented herself
with murmured interjections, to fill up the pause before Mrs.
Bonnington went on again:
“However, I have got a clew to where she came from, for a van-
load of furniture came down before she arrived, and it came from
Todcaster.”
“Todcaster!” echoed Mrs. Rose. “Then we shall soon know
something more about her. Mr. Rose’s old friend, Mrs. Haybrow, is
coming down to see us early next month. She lived near Todcaster
when she was a girl, and she often goes back to the old place, and
keeps in touch with all the people about there.”
“Well,” said Mrs. Bonnington, rising from her chair, and speaking in
a rather more stilted tone than at first, with the consciousness that
her news had hardly been received as she had expected, “I sincerely
trust we may find we have been mistaken. No one will rejoice more
unfeignedly than I if she proves to be indeed what she gives herself
out to be. Indeed, if she had received me frankly at the outset, I
would have shown her such Christian sympathy as one soul can give
to another without asking any questions. And it is only in the
interests of our young people that I lift up my voice now.”
The Vicar’s wife then took her leave, and went on her way to
complete her morning rounds. She was rather a terrible person, this
little, faded middle-aged woman with the curate’s voice and the
curate’s manner, uniting, as she did, a desperate interest in other
people’s affairs with a profound conviction that her interference in
them could only be for good. But she had her good points. A
devoted, submissive, and worshipful wife, she modified her worship
by considering herself the Vicar’s guardian angel. A parish busybody
and tyrant, she never spared herself and could show true womanly
kindness to such of her husband’s parishioners as were not of “a
froward spirit.”
Unluckily, she had not the power of conciliating, but had, on the
contrary, a grand talent for raising up antagonism in unregenerate
minds like those of the unfortunate Mabin.
The young girl had been both sorry and ashamed at her own loss
of temper. Not that an outburst such as that she had indulged in was
any unusual thing. Like many young girls of spirit under injudicious
rule, Mabin was in a state of perpetual friction with those around her.
Her step-mother was not intentionally unkind; but poor Mabin had to
suffer from the constant comparison of her unruly and independent
self with her quiet and insipid half-sisters.
And the worst of it was that her father was even less indulgent
than his wife to her waywardness. A stiff, straight-laced, narrow-
minded man, accustomed to be looked up to and deferred to by the
female members of his household, he disapproved in the strongest
manner both of the erratic moods of his eldest daughter, and of her
longing for independence. It was from him, indeed, that Mabin chiefly
suffered. She looked upon the cold, handsome, aquiline face of her
father with something very much like horror, and the mere fact that
he approved only of submissive “womanly” women seemed to goad
her into the very rebelliousness and independence which shocked
him so deeply.
At the same time that he disapproved of her, however, Mr. Rose
did not hesitate to avail himself of his daughter’s bright wits; and if
any task requiring a little thought or a little judgment presented itself,
it was always upon Mabin’s shoulders that he put the burden.
He had even gone so far, protesting loudly the while against the
“unfeminine” practice, as to allow Mabin to ride a bicycle; and it was
on this machine that the girl was expected to go into Seagate two or
three times a week, to fetch him his books and magazines from the
local library.
As Mrs. Bonnington descended the steps of the big stone house,
and, emerging from the portico, made her way down the broad
gravel path to the gate, she met Mabin coming out by the side gate
among the evergreens with her bicycle by her side.
Now if there was one thing more detestable in the eyes of the
Vicar’s wife than another, it was a bicycle. But this detestation
increased tenfold when the rider of the obnoxious machine was a
woman. It was her one grievance against upright Mr. Rose that he
allowed his nineteen-year-old daughter to “career about the country”
on the abominable thing.
She uttered an involuntary “Ugh!” of disgust as the thing almost
touched her uplifted skirts.
“I beg your pardon. I hope I didn’t run against you. I am so
clumsy,” said Mabin with studied politeness.
“You can’t expect to be anything but clumsy while you use such a
thing as that!” said Mrs. Bonnington severely. “I wish for your own
sake it would get broken, that you might never be seen in an attitude
so unbecoming to a gentlewoman again.”
“Is it you who tell your sons to throw stones at it when I am riding
past the Vicarage?” said Mabin, trying to speak civilly, while the
blood rose to her cheeks. “Walter struck the hind wheel two days
ago, and now I have to walk as long as I am within stone’s-throw of
your garden wall.”
“I have heard nothing about it,” said Mrs. Bonnington icily.
“Of course you wouldn’t,” said Mabin, keeping her tone in check.
“But I see Rudolph has taken to riding one too since he’s been back.
So if they throw stones at me, I can have my revenge upon him,” she
concluded darkly.
“If girls unsex themselves, they can’t expect to be treated with the
chivalry they used to receive,” said Mrs. Bonnington, as, not caring
to continue the encounter with the rebellious one, she turned her
back, and went down the hill.
CHAPTER II.
A PENITENT.

Mabin looked at Mrs. Bonnington’s retreating figure, half regretfully


and half resentfully. The regret was for her own incivility; the
resentment was for the want of tact which had provoked it.
Mabin, like so many other young girls on the threshold of
womanhood, lived in a constant state of warfare both with herself
and her neighbors. Sensitive, affectionate, hasty tempered and
wilful, she was at the same time almost morbidly modest and
mistrustful of herself; so that she passed her time in alternate bursts
of angry resentment against those who misunderstood her, and fits
of remorse for her own shortcomings.
She now mounted her bicycle with the feeling that the Vicar’s wife
had spoilt her morning’s ride for her. Not by any means a vain girl,
she underrated her own attractions, which included a pretty, gray-
eyed little flower-face, a fair skin, and short, soft, dark-brown hair.
But she was keenly alive to the reproach of clumsiness, which had
so often been cast at her. She had shot up, within the last three
years, to a height which, together with the girlish leanness of her
figure, had caused her to be called, even outside the family circle, “a
lamp-post” and a “gawky creature.” And although she stubbornly
refused to take to the long skirts which would have lent her the grace
she wanted, she nourished a smouldering indignation against her
traducers.
And chief among these were the boys of the Vicarage, against
whom, as against their mother for her criticisms, and their father for
his dull sermons, her spirit was always in arms.
The strife between the Bonningtons and the Roses had not always
been so keen. Indeed, in the old days when they were children
together, Mabin and Rudolph had got on well enough together, and
had exchanged love-tokens of ends of slate pencil, lumps of chalk,
and bird’s eggs. But with advancing years had come first coolness
and then estrangement. So that it was now the correct thing among
the Bonnington boys to laugh at Mabin for being “advanced,”
“superior,” “a New Woman,” and a “fright;” while she, on her side,
treated them with lofty contempt as “savages” and “boors.”
Mabin had not gone twenty yards, however, on her way up the
slight ascent, when she saw something which diverted her thoughts
from the Vicarage people. The gates at “The Towers” were wide
open, and Mrs. Dale’s smart victoria, with its well-matched pair of
small, dark-brown horses, came out so suddenly that Mabin had to
jump off her bicycle to avoid a collision. Alone in the carriage sat a
lady in deep mourning, who turned and looked out anxiously at the
girl, and stopped the carriage to speak to her.
“I’m so sorry! I hope you didn’t hurt yourself, in having to jump off
so quickly?” asked the lady in black, in a sweet, plaintive voice that
struck some chord in Mabin’s heart, and made the girl gasp, and
pause before she could answer.
“Oh no, oh no, thank you. One often has to do that,” stammered
the girl, flushing, and speaking with a shy constraint which made her
tone cold and almost rude.
And she knew it, poor child, and was miserable over it; miserable
to think that now when she had an opportunity of speaking to the
being who had excited in her an enthusiastic admiration, she was
throwing her chance away.
A common and a most tragic experience with most young girls.
One thing, however, Mabin was able to do. In the shy look with
which she returned Mrs. Dale’s kind gaze of inquiry, she took in a
picture of a lovely woman which remained impressed on her mind
ineffaceably.
Mrs. Dale was a lovely woman, lovelier than Mabin had thought
when she only got glimpses of the lady’s profile from her seat in
church, or peeps at her through a thick black veil. Mrs. Dale wore a
black veil to-day, but in the open carriage, in the full glare of the sun,
her beauty was evident enough.
A little woman, plump, pink, childlike in face and figure, with wavy
fair hair, infantine blue eyes, and a red-lipped mouth which was all
the more lovable, more attractive for not being on the strict lines of
beauty, Mrs. Dale had, so Mabin felt, exactly the right features and
the right expression for the sweet voice she had just heard. And
through the beauty, and through the voice, the girl, inspired perhaps
by the mourning dress, thought she detected a sadness which
seemed to her the most pathetic thing in the world.
In two moments the interview was over; Mrs. Dale had smiled
upon her sweetly, bidden her farewell merely with a bend of her
head, and driven away, leaving Mabin to scold herself for her idiocy
in throwing away an opportunity which she might never have again.
She did not try to overtake the carriage; she watched it down the
open road, until the shining coil of silky fair hair under the black
crape bonnet grew dim in the distance. And then, with a shrug of her
shoulders and a murmur that “it was just like her,” Mabin turned
defiantly into the road which led past the Vicarage.
However, nobody was about to throw stones at the bicycle on this
occasion; and it was not until she had reached Seagate, changed
her father’s books at the library, and matched a skein of cable silk for
Emily, that she was reminded afresh of the existence of the
Bonningtons by the sight of Rudolph, in his knickerbockers and
gaiters, standing by his bicycle while he lit a cigarette.
Unconsciously Mabin frowned a little. And unluckily Rudolph saw
the frown. She meant to pass him without appearing to notice him,
but he foresaw the intention, and was nettled by it. For Rudolph, with
his black eyes and curly black hair, and his sunbrowned face, was
the handsomest fellow in the neighborhood when he was on shore,
and was accustomed to a great deal of kindness and civility from
Mabin’s sex. Her rudeness, which arose more from shyness than
from the lofty contempt he supposed, puzzled the young fellow, and
made him angry. He remembered their ancient comradeship, which
she seemed to have forgotten; and most unwisely he let a spirit of
“devilment” get the better of him, and addressed her as if they had
been still on the old terms.
“Good-morning, Mabin,” said he.
She gave him a bend of the head, without looking at him, and was
passing on to the place where her bicycle stood outside the door of a
shop. But he would not let her escape so.
“Mayn’t I offer you a cigarette?”
To do him justice Rudolph had not noticed that a small boy with a
basket stood near enough to hear. The boy burst into shrill laughter,
and Mabin turned fiercely. For once she did not stoop.
“I’m afraid you have forgotten a great deal since you went to sea,”
she said in a voice which she could not keep steady.
The young man was surprised, and rather shocked at the way in
which he had been received. He had been anxious to heal the
breach between her and himself, and he had thought that a dash into
their old familiarity might avail where more carefully studied attempts
had failed.
Before he could do more than begin to apologize, to appeal to
their old friendship, Mabin had got on her bicycle and ridden away.
The sun was beating down fiercely by this time upon the white
chalky roads; but Mabin rode on recklessly, at a higher speed than
usual. She was well on her way back to Stone, when, turning her
head to look along the road she had come by, she perceived that
Rudolph was not far behind. She had forgiven his indiscretion by this
time, and rather hoped that he was following quickly on purpose to
“make it up.” So she went on her way through a group of straggling
cottages, at a rather slower pace.
There was a sharp bend in the road at this point, and just as she
sounded her bell in turning the corner, she saw Rudolph, who was
now close behind, dismount and pick something up from the road.
The next moment something struck the front wheel of her bicycle,
and she and her machine were flung with violence down in the road.
She had time to utter a cry, no more, before the crash came.
Then she remembered nothing, knew nothing, until she heard
somebody sobbing close to her ears; and opening her eyes, she saw
the sweet face of Mrs. Dale, with the black veil thrown back, and with
tears in the blue eyes, leaning over her tenderly.
Mrs. Dale uttered a cry of joy, and another voice, which Mabin
recognized as Rudolph’s, said: “Thank God! she isn’t dead, at any
rate.”
“Are you better, dear? Are you in any pain?” asked Mrs. Dale with
so much solicitude that answering tears of sympathetic emotion
started into the girl’s own eyes.
“I am quite well, quite well,” said Mabin. “Only—only—I think my
foot hurts.”
Rudolph and Mrs. Dale exchanged glances.
“I thought so,” said he. “She’s broken her ankle.”
Mrs. Dale’s pretty eyes began to fill again.
“We must lift her into the carriage,” said she. “And you will go on
and prepare her mother, and see that a doctor is sent for at once.”
And, in spite of the protests she feebly made, Mabin was gently
raised from the ground by Rudolph’s strong arms, and helped into
the victoria, where Mrs. Dale took her seat, and, telling the
coachman to drive slowly, insisted on making her own plump little
shoulder the pillow for the girl’s head.
But Mabin, having recovered her spirits, if not her walking powers,
wanted to talk to the new friend she had so unexpectedly made.
“You are very good to me,” she said. “I have never had so much
kindness from any one since my mother died. It was so strange;
when I woke up just now I felt what I thought was my mother’s touch
again. And yet I had forgotten all about that. For she has been dead
fifteen years.”
“Poor child!” said Mrs. Dale. “I am glad of that, dear, that I
reminded you of her,” she whispered gently.
“Of course I don’t mean that,” went on Mabin quickly, trying to sit
up. “I don’t mean that you could be a mother to me now, as I am.
That does sound ridiculous! You couldn’t be my mother when you
are the same age as myself.”
As a matter of fact, Mabin looked older than her companion. But
when the conversation thus turned to herself, Mrs. Dale’s pink face
grew suddenly pale, and Mabin looked at her shyly, and flushed,
feeling that she had said something wrong. But almost before she
was conscious that she had touched some sensitive spot, Mrs. Dale
said softly:
“Go on talking, dear, about your mother, or—or anything. I am
lonely, you know; very lonely. And it is a treat to hear you talk.”
The girl flushed again, this time with surprise.
“You like to hear me talk! Ah, then you must be lonely indeed. For
they say at home I never talk without saying the very last thing I
ought to say.”
As she came to the end of her speech, Mabin found that her words
insensibly began to run the one into the other, and that her voice
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