A Software Engineer Learns Java And Object Orientated Programming Cameron instant download
A Software Engineer Learns Java And Object Orientated Programming Cameron instant download
https://ebookbell.com/product/a-software-engineer-learns-java-
and-object-orientated-programming-cameron-43039484
https://ebookbell.com/product/a-software-engineer-learns-java-and-
object-orientated-programming-1st-dane-cameron-6769022
https://ebookbell.com/product/a-software-engineer-learns-java-and-
object-orientated-programming-dane-cameron-43187710
https://ebookbell.com/product/a-software-engineer-learns-java-and-
object-orientated-programming-cameron-22783254
https://ebookbell.com/product/a-software-engineer-learns-java-and-
object-orientated-programming-dane-cameron-cameron-22783292
A Software Engineer Learns Java And Object Orientated Programming
Cameron
https://ebookbell.com/product/a-software-engineer-learns-java-and-
object-orientated-programming-cameron-22783336
https://ebookbell.com/product/a-software-engineer-learns-
html5-javascript-and-jquery-a-guide-to-standardsbased-web-
applications-dane-cameron-50196032
https://ebookbell.com/product/a-software-engineer-learns-
html5-javascript-and-jquery-a-guide-to-standardsbased-web-
applications-1st-ed-cameron-11839472
https://ebookbell.com/product/a-software-engineer-learns-
html5-javascript-and-jquery-a-guide-to-standardsbased-web-
applications-2nd-dane-cameron-4953372
Building A Game With Unity And Blender Learn How To Build A Complete
3d Game Using The Industryleading Unity Game Development Engine And
Blender The Graphics Software That Gives Life To Your Ideas Lee Zhi
Eng
https://ebookbell.com/product/building-a-game-with-unity-and-blender-
learn-how-to-build-a-complete-3d-game-using-the-industryleading-unity-
game-development-engine-and-blender-the-graphics-software-that-gives-
life-to-your-ideas-lee-zhi-eng-38495364
A Software Engineer Learns Java and Object Orientated
Programming
By Dane Cameron
© 2015 Cisdal Publishing
Cisdal
dane@cisdal.com
www.cisdal.com
Table of Contents
Preface
Introduction to Java
Hello World!!!
Data-types
Language Fundamentals
Operators
Debugging
Object References
Inheritance
Composition
Constructors
Exception Handling
Methods
Collections
Generics
Unit Testing
Enumerated Types
Inner Classes
Lambda Expressions
Streams API
Properties Files
Default Methods
Threading
Parallel Programming
Java Doc
Logging
Conclusion
Design Patterns
Template
Abstract Factory
Factory Method
Singleton
Clone
Visitor
Iterator
Command
Builder
Decorator
Preface
Tell me and I forget. Teach me and I remember. Involve me and I
learn.
Benjamin Franklin
I wrote my first Java code in 1998, just 2 years after its initial release.
In the subsequent 17 years I have continued to use Java, including
as a professional software engineer for the last 16 years.
A lot has changed in the world of technology in the last 17 years, but
in many ways Java has remained a beacon of stability. The code I
wrote 17 years ago does not look vastly different from the code I
wrote last week, and that code I wrote 17 years ago would still run
on modern versions of Java (for the most part).
Despite the fact that the Java language has remained relatively
stable, the role Java plays in the work of IT has changed
dramatically. Java first came to prominence as a language for writing
browser based applications (called Applets). Applets created a huge
sense of excitement around the language through the later part of
the 1990s and the Dotcom boom, but have fallen by the wayside as
native browser-based technologies have continued to improve.
This book is my attempt to pass on what I have learned over the last
17 years. It is not intended as a simple primer on the syntax of the
Java language (although the syntax of the language is covered in
detail), it is intended to introduce you to the way a software engineer
thinks about Java, and the way they structure their code in a world of
large-scale, and increasingly complex software.
The intention of this book is to leave you in a position where you can
write useful, real-world Java programs that solve interesting
problems. This book will not teach you everything you know to
become an expert Java programmer; much of that knowledge can
only come through experience. I have, however, tried to write the
book I would want to read if I was starting from scratch with Java.
1
Introduction to Java
Java is a statically typed object-orientated programming language.
That sentence may mean a lot to you, or it may mean nothing. Rest
assured, this sentence will make sense to you by the end of this
book.
Java does not easily fit into either of these categories. Java is a
compiled language: all source code must be compiled before it can
be executed. As you will see, the Java Development Kit (JDK)
contains a utility program called javac that is responsible for
compiling Java source code.
If you use Windows or OSX you have probably noticed that you are
often requested to install a new version of Java: this is the Java
Runtime Environment. Once Java is installed you can run any
application written in Java.
You may be wondering why Java uses this approach? Java bytecode
can be thought of as a halfway house between source code and
machine code. It contains a set of instructions that can be executed
by an interpreter more efficiently than regular source code.
Java has not been an interpreted language for a long time however.
Almost all Java runtimes now use an approach called Just-in-Time
(JIT) compilation. The Java bytecode is compiled into machine code
as the program runs, just before it is needed. Although there is still
some overhead in this process, Java tends to perform as well as
compiled languages; with the added benefit that the same Java
bytecode can be run on many different operating systems.
Once you have defined your type-system, you can start using these
types (by generating objects from them). In a statically typed
language the compiler can always determine which type you are
referring to. If you attempt to invoke behavior that is incompatible
with the type you are using the compiler will know. For instance, if
you try to rent a Customer to a Car, the program will know this is
invalid and generate an error. This means you never ship the faulty
version of the software to your customers.
With a dynamically typed language the compiler does not know what
types you are using, and therefore you can invoke any operation on
any type. It will not be until the program actually runs that the
language will determine whether the code is valid, and as a result
dynamically typed software can be more error prone.
That is all that you need to know about Java to begin – its time to
write some code.
2
About this book
Who is this book for?
The books in the “Software engineer learns” series are typically
intended for existing programmers and software engineers
transitioning from other languages or technologies. This particular
book is also appropriate for anyone aspiring to become a software
engineer, and who wishes to use Java as his or her starting point.
The key purpose of this book is to provide you the skills required to
become a competent software engineer. This means gaining a firm
understanding not only of the language fundamentals, but also an
understanding of how the language should be used to create a
maintainable and adaptable code base
Java is now seldom used to implement rich GUI applications that run
natively on desktop computers (although it is widely used to write
native mobile applications via the Android SDK). For this reason this
book will not examine the two main Java APIs for creating desktop
applications: Java FX and Swing. This is a shame; because it is
always nicer to write programs that can be interacted with via a GUI,
but the reality is that you are unlikely to use these APIs in
professional environments.
This book will also not focus on exhaustive lists of APIs. Web based
resources have improved significantly over the years, and they are
now by far the best source of information on specific APIs when you
need them. What these web based resources are not so good at,
however, is providing you the bigger picture of when the API should
be used, and what its trade-offs are. This is where a book such as
this can become valuable.
Before you start it is best that I warn you that Java is a large and
complex language. A similar book for many other programming
languages would be at most half the size of this book. I have tried to
write the shortest book that I could, but I simply couldn’t make it any
shorter than I have without omitting important material.
I also would like to apologize up front for the fact that many of the
programs in this book, particularly in the early chapters, are not
solving interesting real-world problems. It is difficult to write
interesting programs until you have a grasp of large portions of the
language, and therefore the early chapters use simple examples.
Versions of Java
This book will focus on Java 8, because this is the latest release of
the language, and contains many significant additions. Throughout
the book I will specifically point out features that relate to Java 8 (and
even Java 7 to some degree), because it is important for you to
know that these are recent additions to the language. There are
massive amounts of Java code already written in earlier versions of
the language, and it may be your job to work with these at some
stage, therefore you need to know the limitations of earlier versions
of the language.
www.cisdal.com/java.html
Source code has been provided in HTML pages rather than Java
code files. The idea is that you can copy and paste this code in
cases where you do not want to type an entire example
Conventions
Code in this book will utilize the following font:
This is code
Instead of endnotes, this book will use the following convention for
asides that are related to the main content, but are not directly
associated with the main content.
// This is an aside
Feedback
I would love to hear your feedback (positive and negative) on this
book. Please email me at dane@cisdal.com. Additionally, reviews
are always appreciated because they are the most important way an
independent publishing house such as ours can gain traction for its
books.
3
Getting started with Eclipse
Technically all you need in order to write Java programs is a text
editor and the Java Development Kit (which includes a Java compiler
and a Java Runtime Environment for executing Java code). In reality,
almost all software engineers who use Java to write non-trivial
programs use an Integrated Development Environment (IDE).
The Eclipse IDE contains everything you will need to write and
execute Java code, including a Java compiler and code editor. This
section will guide you through the process of installing Eclipse.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-
downloads-2133151.html
Once downloaded, install the dmg file just like any other OSX
application.
You should now download Eclipse: open your favorite browser and
navigate to http://www.eclipse.org/. Click the “Download” button on
the homepage, and select to download the latest version of Eclipse
for your platform. I will use the “Luna” release of Eclipse (version
4.4), but if a more recent version is available you can choose to use
it.
Install on Windows
Before installing Eclipse, it is important to ensure you have the latest
version of Java installed. Specifically, you need to ensure you have a
Java 8 JDK installed (a Java JRE is not sufficient), this can be
downloaded from the following web site:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-
downloads-2133151.html
Once downloaded, install the downloaded file just like any other
Windows application.
You should now download Eclipse: open your favorite browser and
navigate to http://www.eclipse.org/. Click the “Download” button on
the homepage, and select to download the latest version of Eclipse
for your platform. I will use the “Luna” release of Eclipse (version
4.4), but if a more recent version is available you can choose to use
it.
Inside the Eclipse folder that has been created you will find a file
called Eclipse.exe. Simply double click on this file to launch Eclipse.
When Eclipse opens for the first time you will be presented with the
screen seen in figure 3-3:
Figure 3-3
Click the “Workspace” icon in the top right hand corner of the screen:
this will take you to the Eclipse workbench, which will appear as per
figure 3-4:
Figure 3-4
Once you have Eclipse up and running you are ready to start
working with the examples in this book.
4
Hello World!!!
There is a common convention when learning a new programming
language that the first program you write is one that prints “Hello
World!!!” to the console.
There is actually a very good reason for this. The act of producing the
most trivial program possible introduces you to many important
concepts, and involves the steps of writing source code, compiling
that code, and executing it.
Before writing any code, first create a project in Eclipse. Projects are
an Eclipse concept rather than a Java concept, and provide a
container for all the code and libraries that constitute a program.
From the main menu choose File -> New -> Java Project.
This option is shown in figure 4-1:
Figure 4-1
Inside the popup, use helloworld as the name of the project. It is
also important to ensure at this point that the execution environment
JRE is JavaSE1-8, as seen in figure 4-2.
Figure 4-2
Once the project name has been entered, simply press the “Finish”
button at the bottom.
You can now write the code to print “Hello World!!!” to the console.
All code in a Java program must be inside a class. I will explain what
a class is in detail in the next chapter, but for now just think of it as a
file containing Java source code. Each class has a name, and must
be created inside a file with this exact same name, along with the file
extension of .java.
Eclipse will always ensure that the name of the class and its filename
are the same, but if you were using a text editor instead of an IDE it
would be important to ensure this yourself.
When a class is compiled it will create a file with the same name, but
a .class extension: this contains the Java bytecode that will be
executed by the JRE.
Along with these conventions, Java does enforce a set of rules for
class names. A class must begin with a character, but can then
contain digits and the special characters “$” and “_”. It is also worth
mentioning at this point that everything in Java is case-sensitive – so
HelloWorld and Helloworld could coexist as two separate
classes.
Anything but the simplest Java program will contain many classes,
therefore it is customary to group classes inside “packages”. A
package is essentially a folder or directory, and is represented by a
directory on the file-system. Just like directories, packages can be
nested inside one another.
To create a class, use the File-> New-> Class option from the
main menu. Alternatively, you could right click on the project name on
the left of the screen and choose New-> Class.
After selecting this option you will be presented with a dialog box, as
seen in figure 4-3, where you can specify the basic details of the
class. Enter hello as the package name, HelloWorld as the class
name, and ensure that you check the option public static void
main(String args[]): I will explain this option shortly.
Figure 4-3
Once these values have been provided, press “Finish”.
Eclipse will create the HelloWorld.java source file, and populate it with
relevant code. This will be displayed to you in the editor, as seen in
figure 4-4:
Figure 4-4
Additionally, if you look at the directory structure that has been
created on the file system it will look like figure 4-5:
Figure 4-5
• The top-level folder is the Eclipse workspace.
You will also notice that the package declaration ends with a semi-
colon. All Java statements must end with semi-colons. Unlike some
languages (I’m looking at you JavaScript), semi-colons are not
optional in Java.
The empty line after the package declaration is not required, but
since white space is ignored in Java, adding an empty line such as
this can improve readability.
You can ignore the keyword public for now, I will explore this in
detail in subsequent chapters. The next keyword class indicates that
you are declaring a class, while HelloWorld is the name of the
class. All Java class files will begin with a similar declaration,
although, as you will see, there are many variants of this declaration.
This line of code ends with a curly bracket rather than a semi-colon.
Curly brackets are used in Java to wrap blocks of code: a “{“
indicates that a code block is beginning, while a “}“ indicates that a
code block is ending. A code block is a grouping mechanism for a set
of statements.
It is worth noting that these lines of code only exists because you
clicked the public static void main(String args[]) option
when you created the class. You clicked that because you wanted to
add a special kind of method to this particular class.
I will ignore the public and static keywords until later chapters. The
next keyword in the signature is void: this indicates the type of data
returned by the method when it finishes execution. Because the
main method does not return any data, it is always declared as
returning void.
The next identifier in the signature, main, is the name of the method.
Method names are usually arbitrary, with the exception that they
conventionally start with a lower case character. As mentioned, the
main name is not arbitrary in this case, because the Java Runtime
Environment will look for a method named main when the program
starts executing.
Notice that these curly brackets are nested inside the curly brackets
for the class itself. Because Java code can consist of many nested
blocks of curly brackets, it is important to indent each block, as seen
in this example.
The final line of code that Eclipse has generated for us is a comment:
// TODO Auto-generated method stub
The println method will print the string it is passed to the standard
output of the program, which in your case will be the Eclipse console.
If you were running this program from an operation system console or
shell, the standard output would be that console or shell.
You can now run the program by selecting Run -> Run from the
main menu. When you choose this option, Eclipse will look for a class
in the project with a main method and run it.
Figure 4-6
Congratulations, you have just written and executed your first Java
program!
Trouble shooting
Even with simple programs such as this, it is important to know how
to trouble shoot problems that may arise. In order to demonstrate
this, go back to the editor and remove the semi-colon from the end of
the following line:
System.out.println("Hello World!!!")
This has introduced a syntax error into the code; meaning Eclipse is
unable to compile it.
Eclipse will warn you that a problem exists in the code by adding a
red dot to the margin of the editor at the appropriate line, as seen in
figure 4-7:
Figure 4-7
If you click on the red dot, Eclipse will tell you what the problem is:
Syntax error, insert ";" to complete
In this case the error tells you exactly what the problem is. Eclipse is
not always so helpful, but usually knowing where the problem is
provides enough information to know how to fix it.
You will also notice that you cannot run a Java program if it contains
any compilation errors. Attempting to run the program now produces
the following message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error, insert ";" to complete BlockStatements
at hello.HelloWorld.main(HelloWorld.java:6)
Conclusion
The Hello World program demonstrated in this chapter is not as
simple as Hello World programs in many other languages. Not only
is it several lines longer than many languages, it is difficult to
concisely explain many features of this program without
understanding more of the language. In fact, I have not explained
many of the keywords used in this program.
This in itself does not make Java a good or bad language, but it does
stem from an important principle in Java: everything is a class. Many
languages, including object orientated languages such as C++ allow
arbitrary code to be included in a source file and executed: Java
insists that all code is placed within a class structure. In many
languages this program could be written as a single line of code, for
instance:
print("Hello World!!! ")
In the next chapter you are going to take a closer look at classes,
and the related concept of objects, this will include a look at some of
the keywords I skipped over in this chapter.
5
Classes and Objects
As mentioned in the introduction, Java is an object-orientated
programming language. Object-orientated programming is a
paradigm that uses the concept of an object to encapsulate the data
and behavior of a program. Objects are reusable modules, and can
interact with one another as the program executes.
You can think of classes as molds. Once you have constructed your
mold you can use it to create as many objects as you like from the
mold.
When you first sit down to write a Java program you need to think
about what the nouns will be. For instance, in a rental car program
the nouns may be Customer, Car and Rental agreement. In a
banking program the nouns may be Customer, Account and Branch.
Once you have defined the nouns, you next start thinking about the
data each of these nouns needs to hold. You describe the data that
will be captured by defining fields on the class. For instance, a
Rental agreement class might contain fields that capture the daily
rate, the date the agreement was signed, and any special charges
that will be applied to the rate. The class defines the fields, while
each object will be assigned specific values for these fields.
Finally you need to think about what behavior is required from the
class; the behavior will be captured in the class’s methods. For
instance, the Rental agreement class might have a method that
calculates the total cost to the customer. In order to achieve this,
methods can read and modify the data held by an object.
You will remember from the Hello World example that you declared a
class called HelloWorld. Before beginning the examples in this
chapter it is worth pointing out a quirk of the Hello World program. In
that program you did not create an object from the HelloWorld
class, yet its main method could still be invoked. This is because
the method was declared as static:
public static void main(String[] arguments) {
Static methods are different from most of the methods that you will
look at in this book because they can be invoked directly on the
class, rather than instances of the class (its objects). This is a
subject I will return to in later chapters.
Declaring a class
You will begin by creating a new project in Eclipse called
ObjectsAndClasses.
Inside this project, create a new class called Car, and place this
class inside a package called vehicles.
Unlike the HelloWorld class from the previous chapter, you will
not check the public static void main(String[] args) option
when creating this class.
When you click “Finish”, Eclipse will generate the following code:
package vehicles;
public class Car {
}
The first step for defining a class is adding its fields. The fields that
the class needs will depend on the program in which the class will be
used. For instance, a Car in a vehicle registration program might
hold very different data to a Car in a taxi booking system.
The process of determining the fields that are relevant for the
program being written is called data-abstraction. This is because you
are creating an abstraction of a Car that models just the information
and behavior that is relevant for the context you are using it in.
In this particular case you will focus on the fields that may be
relevant for a car in a vehicle registration system, therefore add the
following fields:
package vehicles;
You have added five fields to this class. Each definition contains
three component parts:
• A data-type: this indicates the type of data that each field holds
Due to the fact that this is a class (or a template for objects), you do
not need to assign values to the fields; the values will be assigned to
each instance (or object) you create from this class.
Another Random Document on
Scribd Without Any Related Topics
power of the stroke immediately the ball is reached."
This is an idea fatal to good golf. As I have frequently pointed out,
and as James Braid in How to Play Golf also emphasises, the
meeting between the ball and the club should be merely an incident.
Any attempt to try to do anything during impact in the drive is futile.
Mr. Travis at page 24 makes the same error with regard to the speed
of the club after the ball has been hit. He says: "A great deal more
depends upon the maintenance of speed after the ball is struck than
is commonly supposed. This part of the stroke is known as the
follow-through, and plays a very important part in the length of the
drive as in straightness." Mr. Travis evidently does not perfectly
realise that the follow-through is of no importance whatever except
as the natural result of the correctly played first part of the stroke,
and the maintenance of speed after the ball has been struck is of no
importance provided that the first portion of the stroke has been
properly executed and at a sufficient pace. The only importance of
the maintenance of speed in any way whatever is that this indicates
that the first half has been correctly performed.
Mr. Travis seems to be very hazy as to the causes of slicing and
pulling. A ball being hit slightly to the right of its centre would not
necessarily produce a slice, although it would probably deflect it
from its intended line of flight. A slice is produced by the amount of
rotation which is imparted to the ball by the glancing blow. He says:
"With a pulled ball it is just the opposite—the ball is hit to the left of
its centre, that is, nearer the player, producing a spin from right to
left." This is not in any way necessary. The ball may be hit absolutely
at the point farthest from the hole, and with the club at a perfect
right angle to the intended line of flight, but the point which Mr.
Travis does not mention is that the club is travelling upward across
the intended line of flight and outward from the player. This it is
which produces the beneficial spin of the ball in the pull.
At page 31, Mr. Travis says: "Every golfing stroke describes a circle,
or a segment of a circle." This is an egregious error, for the golf
stroke, quite naturally from the method of its production, bears a far
greater likeness to an oval than to a circle. Anyone endeavouring to
produce the golf stroke as a circle would certainly not get either a
very graceful or a very accurate result. Mr. Travis falls into the
astonishing error for a man who plays golf so well as he does, of
thinking that it is possible to juggle with the golf ball by means of a
golf club during impact. Speaking of brassy play, he says: "The
lofted face, joined to the slight whipping up of the hands at the
proper time—that is after the club meets the ball—will produce the
desired result. Don't on any account seek to bring the hands up too
quickly, otherwise a top will assuredly result."
Mr. Travis here falls into the common error with regard to using the
wrists during impact. It will be observed that he avoided it in dealing
with the follow-through, but in this matter he makes the usual error.
This turning up of the wrists which he refers to comes long after the
ball has been hit, and is the natural turn up which follows any slice
or any cut played to raise a ball suddenly.
At page 41 he makes the same error, for he says: "By striking the
ball slightly towards the heel of the club, and immediately after
bringing the arms somewhat in and finishing well out, a slight spin is
imparted to the ball which causes it to rise more quickly." Here it is
clear that he thinks that one may, after impact, do something with
the hands to affect the manner in which the ball leaves the club.
There could not possibly be any greater fallacy in golf than this. That
this is a rooted fallacy of Mr. Travis I shall show later on when I deal
with his remarks about bunker play.
Mr. Travis says at page 49: "Hitting with the heel of the club meeting
the ground after the ball is struck will cause the ball to rise more,
and, joined to the spin imparted by drawing in the arms and turning
the wrists upward, will produce a very dead ball with hardly any run.
The science of the stroke consists in hitting very sharply, and turning
the wrists upward immediately after the ball is struck."
Here we see the same delusion. The essence of this stroke is purely
a matter of practical golf which I have not seen mentioned in any
book or essay on golf. When one plays a ball off the heel of one's
mashie, it stands to reason that one gets the ball on the very
narrowest portion of the blade, and that therefore one hits the ball
as far beneath the centre of the ball's mass as it is possible to do—
so much so, in fact, that a very considerable portion of the ball
overlaps the top of the face of the club. This puts a tremendous
amount of undercut or stop on the ball. This is the practical golf of
the shot which Mr. Travis is attempting to describe, but his idea of
putting cut on it by juggling with it during impact is fatal.
In speaking of approach puts, Mr. Travis gives some wonderful
advice. He says: "You should aim to hit the ball as if it were your
intention to drive it into the ground.... This will cause the ball to
jump, due to its contact with the ground immediately after being
struck." This is practical golf of a nature which we may very well
pass without discussion. I think that there are very few golfers who
will desire to bounce the ball off the earth when they can play it off
the face of the club.
This is Mr. Travis' advice as to how to cut the put. At page 65 he
says: "Put cut on the ball by drawing the arms in a trifle just at the
moment of striking." The drawing of the arms across the ball is not
to be done at the moment of striking. It starts at the beginning of
the swing and finishes at the end thereof. This is how cut is put on a
put by practical golf. Mr. Travis advises for putting that people should
select "a particular blade of grass" on the line to the hole. He then
says: "Take your stance and square the face of the putter at perfect
right angles to the blade of grass you have picked out." As a matter
of practical golf I may remark that blades of grass have a
remarkable family likeness.
Mr. Travis says: "Close observation of all missed puts discloses the
interesting fact that by far the large majority go to the left of the
hole, thereby indicating the presence of the pull, due to the arms
being slightly drawn in just after striking." This is what is called a
sliced put in England, but again as a matter of practical golf I may
say that many of these puts are simply misdirected, such
misdirection being due to the turning over of the wrists too soon in
the action of striking the ball. Unless one determinedly follows
through well down the line the natural tendency is to hook one's put
across the line, but this does not indicate any pull. It merely
indicates, if of frequent occurrence, ignorance or carelessness.
Speaking of stymies, Mr. Travis says: "Occasionally you will be
confronted with an absolutely dead stymie by having your
opponent's ball just on the edge of the cup, your own being so
close, say seven inches to a foot away, that it is impossible to
negotiate the stroke by either curling around or lofting. In such
extremity there is only one way of getting your ball in the hole
unaccompanied by your opponent's, and that is by what is
technically known in billiards as the follow shot." As a matter of
practical golf the stymie stroke introduced by me is far more likely to
prove successful in this case than the follow shot, for we are dealing
with very tricky things when we try to play billiards with golf balls
covered with numerous excrescences or dimples. If the stymie
described by Mr. Travis is played by my stroke, it should be got five
times out of six, and I very much doubt if Mr. Travis or anybody else
could get anything like this with the run through stroke.
Writing of "Playing out of hazards," Mr. Travis says: "Then bring it
down again on the same line with all the force you can controllably
command, consistent with accuracy. As it sinks into the sand its
course may then, but not until then, be slightly directed towards the
ball."
Coming from a practical golfer this is an absolutely amazing
statement. The idea of attempting to deflect one's niblick from the
line originally mapped out for it as it enters the sand is too amazing
and too utterly unsound to merit any further comment or notice,
except to say that it would be impossible to deflect the club head
from the line of travel mapped out for it at this moment without
materially reducing the force of the blow, and when one is hitting
into heavy sand, to get underneath the ball and in many cases to
get it out of the bunker without even touching it with the club, every
pound of force that can be put into the club is necessary.
There is another thing which Mr. Travis tells us that certainly is not
practical golf, and it does not seem to me to be practical carpentry,
but he says at page 126, speaking of the brassy: "The screws which
hold the blade sometimes work loose. This trouble may easily be
remedied by putting glue in the holes before inserting the screws."
One is never too old to learn, and I think that in any future efforts I
may make at amateur carpentry, I shall glue my nails!
Mr. Travis makes a very remarkable statement at page 139, speaking
of the guttie ball as opposed to the Haskell: "The latter, by reason of
its greater comparative resiliency does not remain in contact with
the club head quite so long, and therefore does not receive the full
benefit of the greater velocity of the stroke in the same proportion
as the less resilient guttie"; but surely the greater the resiliency of
the ball the longer it will remain in contact with the club. It should
be obvious that one of the reasons for the greater swerve in the
sliced or pulled rubber-cored ball as compared with the guttie, is
that on account of the longer period of impact the ball acquires a
greater amount of spin.
Speaking of the waggle, Mr. Travis is delightfully indefinite. He says
"With the club gripped pretty firmly with both hands in the manner
already described, it is well to see that the whole machinery is in
good working order by waggling the club a few times over the ball,
allowing the wrists to turn freely, without, however, relaxing the grip.
The waggle should be entirely free from any stiffness, which simply
means that the wrists should be brought into active play."
This is certainly delightfully vague, and is not, I am afraid, of much
use to anyone as a matter of practical golf. The waggle is
unquestionably of importance in the game of golf, otherwise it is
quite improbable that we should see it employed by so many of the
famous players. The curious thing about this waggle is that it seems
to be confined to games wherein one plays a stationary ball. The
same operation is gone through at billiards with the cue, but is there
known as cueing at the ball. With a very great number of players the
waggle may be described as moral cowardice—an excuse for putting
off the evil moment. Many players convert the waggle into a
performance which is both tedious and stupid, and which instead of
giving them a better chance of hitting the ball, has a very great
chance of absolutely putting them off their stroke.
I do not know that I have ever seen the necessity for the waggle
explained, nor have I seen the waggle of any of the famous players
illustrated. There can, however, be very little question that in the
majority of cases the address and waggle is unnecessarily
exaggerated and prolonged.
In Modern Golf I have illustrated George Duncan's waggle. So far as
I am aware, this is the only time that such a thing has been done.
Duncan is probably the quickest player living, so that it will not be
necessary for us to assume that every one will be satisfied with so
little preliminary work as Duncan puts in before hitting the ball. His
method of playing is to take his line to the hole as much as he can
as he approaches the ball. He then marches straight up to it and
takes his stance, at the same time swinging his club head out so
that it is roughly on a level with his waist and pointing towards the
hole, but being at the same time almost above the line of flight to
the hole. He then brings his club back to the ball, and addresses it in
the usual way, soling his club close behind the ball. Now he lifts the
club practically straight up for six or nine inches and carries it
forward of the ball in a gentle curve for about six inches. From here
he carries the club head back along the plane of flight produced
through the ball as far as it will go without turning his wrists over.
The club then is swung easily and naturally back to the ball almost in
the same manner as it would come to it in the drive, until it arrives
close behind the ball, but about two inches from the turf, when it
sinks to rest by dropping straight down behind the ball. It is now
soled again as in the original address.
This sounds like a somewhat lengthy process, but as a matter of fact
it is probably the shortest waggle used by any golf player who is in
the front rank. In fact, so rapid is Duncan in his play, that very
frequently spectators who are not accustomed to his methods, do
not see him play the ball, as they allow for the more deliberate style
generally followed by the other leading professionals. In Duncan we
have a player who in my opinion is as good a golfer as anyone in the
world. We see clearly that he wastes very little time in addressing his
ball, either through the green or on the putting-green. On the other
hand, we see some men of greater fame than Duncan whose
deliberation is tedious in the extreme, although it must be admitted
that in so far as regards the waggle in the drive, the great players do
not overdo this nearly so much as do amateurs of an inferior class.
I am not aware that anybody has yet explained the reason for the
waggle. It seems that it is a natural movement, or in some cases a
very unnatural movement, which players fall into in endeavouring to
readjust their distance from the ball and their position with regard to
the line of flight. Very many players who waggle, produce most
remarkable flourishes with their club. The club is made to describe
curves in the air which it could not possibly do in any other
operation at golf than the waggle. The whole object of the waggle
seems to be to allow the player to get his eye in, as it is commonly
called, at the ball, to loosen his joints, and, which is a point that I
have not seen previously made, in a measure to produce in
anticipation the motions of his wrists and club immediately before,
at, and after impact with the ball.
If this view of the object of the waggle be accepted as correct, it is
obvious that in nine cases of ten the attempted waggle is force
hopelessly wasted—in fact, worse than wasted, for it has been
occupied in describing weird geometrical figures in the air, figures
which can have no possible reference whatever to the work which
the club is expected to do. In Duncan's waggle it will be observed
that firstly he swings his club head out down the line towards the
hole, and secondly that he carries it back for a considerable distance
from the ball in the plane of flight produced through the ball. It will
be seen from this that to a great extent he produces in the waggle
the same motions as his forearms and wrists go through
immediately before, at, and after impact with the ball. On examining
the photographs of Duncan's hands in the drive, we find that for the
space of nearly two feet before he reaches the ball, and probably for
quite that distance after the ball has been struck and he has
continued the follow-through, there is no turning over of the wrists—
that during this space of roughly three feet, the space wherein
James Braid says that the wrists have it all their own way, Duncan's
wrists are practically quiescent, and that during the whole of this
time the club is travelling at almost its maximum speed, but the
arms and wrists are doing very little more to it than to withstand the
centrifugal force developed in the earlier part of the swing and to
keep themselves braced to withstand the shock of impact.
These are merely a few instances taken haphazard from a book
called Practical Golf by one who is, undoubtedly, in so far as regards
his own play, a practical golfer. This does not, however, prevent him
from furnishing another and a very striking example of the curious
fact that nearly all good golfers teach the game in a manner entirely
different from that in which they play it, and that their tuition, if
followed out, must result in their followers learning to play in very
bad form, and probably also learning much which has to be painfully
unlearnt later on when they have discovered the truth.
AFTERWORD
It would be very easy for me now to begin to explain in the ordinary
manner of golf books how the game is played, but to do so would be
going outside the scope of this work, and interfering either with the
proper functions of the professional, or the proper practice of the
intelligent golfer.
I have, in this book, taken my readers through all those matters
which are of the most vital importance to the game, and practically
everything which is contained between the covers of this book may
be better studied and digested by the golfer, be he a champion or a
beginner, in his arm-chair than on the links. He who wishes to know
golf to the core, must know what is in this book, all of which he can
thoroughly understand without taking a club in his hands.
The whole fault of the false doctrine which has been so plentifully
published about golf in the past, is that it has given the unfortunate
people who have taken notice of it an incalculable number of things
to think about. The truest and best tuition in golf is that which
advances by a process of elimination and so proceeds that it gives
the learner a minimum number of separate circumstances to think
about during his game; in fact, if the tuition has been properly
carried out the golfer will have astonishingly little to think of at the
moment when he is making his stroke. This is the ideal condition of
mind. The remark which the puzzled golfer made to me that when
he started on his downward swing he had so many things to think of
that he was "all of a dither" expresses marvellously accurately the
condition of mind of about ninety per cent of golfers who think they
have studied golf.
The golfer who studies this book soundly and intelligently will learn
what he will learn from no other book on golf, and that is what a
vast number of things there are in connection with the golf stroke
which it is expedient to forget at the moment one is making it.
Let me give an illustration of what I mean. The golfer is told now
that at the top of his swing he must get his weight on to his right
foot, and that he must keep his head still. The merest attempt to do
this produces a conflict at once. Then he is told that his left hand
must dominate the right: here is conflict again. But when he learns
that in order to keep his head still he must put his weight at the top
of his swing on his left foot, the conflict vanishes, he finds that it is
natural and easy to do; and he forgets to encumber his mind with
the fact that it has to be done, so that it becomes just as habitual
with him to put his weight in the right place as it is when he is
walking. The same thing applies with regard to the instructions
which he has always had drilled into him to allow the left hand and
arm to usurp the position of the right. Here again he is distinctly
exhorted to encourage these two members to enter into conflict
during the stroke. Although I explained to him most clearly that this
idea about the left being the more important member of the two is
utterly wrong, and that the right is, and always must be, the
dominant member in the golf swing, I did not tell him to remember
this during the golf swing, and he is indeed a very foolish person if
he attempts to remember it. All he has to do is to cut the false
doctrine out of his mind, and nature will attend to the rest. So it will
be seen that when one has grasped the truth in connection with golf
one has advanced by such a process of elimination that there is left
for the happy golfer when he addresses his ball very little to think of
but hitting that ball.
Golf in the past has suffered from the multiplicity of false directions.
It is by recognising these for what they are, and by forgetting them
that the golfer will ultimately arrive at The Soul of Golf.
INDEX
Accelerating speed, Vardon on, 104
Address and impact similar, Braid on, 137
Address, Braid on, 133
Apportionment of back-spin, 263, 270, 271
Arm roll in stroke, 210
Arms measure distance, 46, 174
As you go up so you come down, 97, 219
Ayres, F. H., Ltd., 289, 324
Ayres, Mr. Rupert, 289-291
Fallacies of golf, 95
Feet, movement of, Duncan, Vardon, and Braid, 134
"Flick" in golf stroke, 213
Flight of ball, 222
Follow-through, 128, 129
control of, 278
Forearms, action of Duncan's, 210
in stroke, roll of, 210
Freemasonry of golf, 6
Fry's Magazine, photographs in, 125, 138
BOOKS ON SPORT
THE ADVENTURES OF AN ELEPHANT HUNTER. By James Sutherland.
Illustrated 8vo. 7s. 6d. net.
A COLONY IN THE MAKING: or Sport and Profit in British East Africa.
By Lord Cranworth. With Map and Illustrations. 8vo. 12s. net.
SPORT ON THE NILGIRIS AND IN WYNAAD. By F. W. F. Fletcher.
Illustrated. 8vo. 12s. net.
THE MAN-EATERS OF TSAVO, AND OTHER EAST AFRICAN
ADVENTURES. By Lieut.-Colonel J. H. Patterson, D. S. O.
Illustrated. With a Foreword by Frederick Courteney Selous. 8vo.
7s. 6d. net. Cheap Edition. Globe 8vo. 1s. net.
IN THE GRIP OF THE NYIKA. Further Adventures in British East
Africa. By Lieut.-Colonel J. H. Patterson, D. S. O. Illustrated. 8vo.
7s. 6d. net.
A HUNTER'S WANDERINGS IN AFRICA. Nine Years amongst the
Game of the Far Interior of South Africa. By Frederick Courteney
Selous. Illustrated. Fifth Edition. Extra crown 8vo. 7s. 6d. net.
AFRICAN NATURE NOTES AND REMINISCENCES. By Frederick
Courteney Selous. With a Foreword by Theodore Roosevelt, and
Illustrations by E. Caldwell. 8vo. 10s. net.
NOTES ON SPORT AND TRAVEL. By George Kingsley. With
Introductory Memoir by his Daughter, Mary H. Kingsley. Extra
crown 8vo. 8s. 6d. net.
AN ANGLER'S HOURS. By H. T. Sheringham. Extra crown 8vo. 6s. net.
Transcriber's Notes
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.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.
• 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 comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
ebookbell.com