Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
276 views

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

Modern

Uploaded by

iluxaamachi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
276 views

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

Modern

Uploaded by

iluxaamachi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Download the full version of the textbook 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/

Explore and download more textbook 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/

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

Saint Joseph of Wisconsin The Heroic True Story of Senator


Joseph McCarthy that Fake News Fake Historians Don t Want
You to Know M S King
https://textbookfull.com/product/saint-joseph-of-wisconsin-the-heroic-
true-story-of-senator-joseph-mccarthy-that-fake-news-fake-historians-
don-t-want-you-to-know-m-s-king/
textbookfull.com
Quantum Fields and Processes A Combinatorial Approach 1st
Edition John Gough

https://textbookfull.com/product/quantum-fields-and-processes-a-
combinatorial-approach-1st-edition-john-gough/

textbookfull.com

EXCEL FUNCTIONS and Advanced Formula Combinations Excel


Mastery Series Unleashing the Power of Spreadsheets 1st
Edition Kiet Huynh
https://textbookfull.com/product/excel-functions-and-advanced-formula-
combinations-excel-mastery-series-unleashing-the-power-of-
spreadsheets-1st-edition-kiet-huynh/
textbookfull.com

Rewilding The Radical New Science of Ecological Recovery


1st Edition Paul Jepson

https://textbookfull.com/product/rewilding-the-radical-new-science-of-
ecological-recovery-1st-edition-paul-jepson/

textbookfull.com

Amity and Prosperity one family and the fracturing of


America First Edition Griswold

https://textbookfull.com/product/amity-and-prosperity-one-family-and-
the-fracturing-of-america-first-edition-griswold/

textbookfull.com

Women in European Holocaust Films: Perpetrators, Victims


and Resisters 1st Edition Ingrid Lewis (Auth.)

https://textbookfull.com/product/women-in-european-holocaust-films-
perpetrators-victims-and-resisters-1st-edition-ingrid-lewis-auth/

textbookfull.com
Love s Someday First Edition Robin Alexander

https://textbookfull.com/product/love-s-someday-first-edition-robin-
alexander/

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 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
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
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
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
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
Random documents with unrelated
content Scribd suggests to you:
*** END OF THE PROJECT GUTENBERG EBOOK TIME GRABBER ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
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.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like