part of Java, which added to its charisma. However, applets rely on a Java browser
plugin. Thus, for an applet to work, it must be supported by the browser. Recently,
support for the Java browser plugin has been waning. Simply put, without browser
support, applets are not viable. Because of this, beginning with JDK 9, the phaseout of
applets was begun, with support for applets being deprecated. In the language of Java,
deprecated means that a feature is still available but flagged as obsolete. Thus, a
deprecated feature should not be used for new code. The phaseout became complete
with the release of JDK 11 because support for applets was removed.
As a point of interest, a few years after Java’s creation an alternative to applets was
added. Called Java Web Start, it enabled an application to be dynamically downloaded
from a web page. It was a deployment mechanism that was especially useful for larger
Java applications that were not appropriate for applets. The difference between an
applet and a Web Start application is that a Web Start application runs on its own, not
inside the browser. Thus, it looks much like a “normal” application. It does, however,
require that a standalone JRE that supports Web Start is available on the host system.
Beginning with JDK 11, support for Java Web Start has been removed.
Given that neither applets nor Java Web Start are viable options for modern versions of
Java, you might wonder what mechanism should be used to deploy a Java application.
At the time of this writing, one part of the answer is to use the jlink tool added by JDK
9. It can create a complete runtime image that includes all necessary support for your
program, including the JRE. As you might guess, deployment is a rather advanced topic
that is outside the scope of this book. Fortunately, you won’t need to worry about
deployment to use this book because all of the sample programs run directly on your
computer. They are not deployed over the Internet.
A Faster Release Schedule
Another major change has recently occurred in Java, but it does not involve changes to
the language or the runtime environment. Rather, it relates to the way that Java
releases are scheduled. In the past, major Java releases were typically separated by two
or more years. However, subsequent to the release of JDK 9, the time between major
Java releases has been decreased. Today, it is anticipated that a major release will occur
on a strict timebased schedule, with the expected time between major releases being
just six months.
Each major release, now called a feature release, will include those features ready at
the time of the release. This increased release cadence enables new features and
enhancements to be available to Java programmers in a timely fashion. Furthermore, it
allows Java to respond quickly to the demands of an everchanging programming
environment. Simply put, the faster release schedule promises to be a very positive
development for Java programmers.
Currently, feature releases are scheduled for March and September of each year. As a
result, JDK 10 was released in March 2018, which was six months after the release of
JDK 9. The next release (JDK 11) was in September 2018. Again, it is anticipated that
every six months a new feature release will take place. You will want to consult the Java
documentation for latest release schedule information.
At the time of this writing, there are a number of new Java features on the horizon.
Because of the faster release schedule, it is very likely that several of them will be added
to Java over the next few years. You will want to review the information and release
notes provided by each sixmonth release in detail. It is truly an exciting time to be a
Java programmer!
The Java Buzzwords
No history of Java is complete without a look at the Java buzzwords. Although the
fundamental forces that necessitated the invention of Java are portability and security,
other factors played an important role in molding the final form of the language. The
key considerations were summed up by the Java design team in the following list of
buzzwords.
OBJECT-ORIENTED PROGRAMMING
At the center of Java is objectoriented programming (OOP). The objectoriented
methodology is inseparable from Java, and all Java programs are, to at least some
extent, objectoriented. Because of OOP’s importance to Java, it is useful to understand
in a general way OOP’s basic principles before you write even a simple Java program.
Later in this book, you will see how to put these concepts into practice.
OOP is a powerful way to approach the job of programming. Programming
methodologies have changed dramatically since the invention of the computer,
primarily to accommodate the increasing complexity of programs. For example, when
computers were first invented, programming was done by toggling in the binary
machine instructions using the computer’s front panel. As long as programs were just a
few hundred instructions long, this approach worked. As programs grew, assembly
language was invented so that a programmer could deal with larger, increasingly
complex programs, using symbolic representations of the machine instructions. As
programs continued to grow, highlevel languages were introduced that gave the
programmer more tools with which to handle complexity. The first widespread
language was, of course, FORTRAN. Although FORTRAN was a very impressive first
step, it was hardly a language that encouraged clear, easytounderstand programs.
The 1960s gave birth to structured programming. This is the method encouraged by
languages such as C and Pascal. The use of structured languages made it possible to
write moderately complex programs fairly easily. Structured languages are
characterized by their support for standalone subroutines, local variables, rich control
constructs, and their lack of reliance upon the GOTO. Although structured languages
are a powerful tool, even they reach their limit when a project becomes too large.
Consider this: At each milestone in the development of programming, techniques and
tools were created to allow the programmer to deal with increasingly greater
complexity. Each step of the way, the new approach took the best elements of the
previous methods and moved forward. Prior to the invention of OOP, many projects
were nearing (or exceeding) the point where the structured approach no longer works.
Objectoriented methods were created to help programmers break through these
barriers.
Objectoriented programming took the best ideas of structured programming and
combined them with several new concepts. The result was a different way of organizing
a program. In the most general sense, a program can be organized in one of two ways:
around its code (what is happening) or around its data (what is being affected). Using
only structured programming techniques, programs are typically organized around
code. This approach can be thought of as “code acting on data.”
Objectoriented programs work the other way around. They are organized around data,
with the key principle being “data controlling access to code.” In an objectoriented
language, you define the data and the routines that are permitted to act on that data.
Thus, a data type defines precisely what sort of operations can be applied to that data.
To support the principles of objectoriented programming, all OOP languages,
including Java, have three traits in common: encapsulation, polymorphism, and
inheritance. Let’s examine each.
Encapsulation
Dostları ilə paylaş: |