James Gosling Object-Oriented Design Unified Modeling Language
INTRODUCTION
Java is a programming language. There are
hundreds of programming languages. But the computer can understand
only one language, namely Machine
language. Other languages have to be translated or interpreted.
We can only use the Binary
Digits in Machine Language which in addition has a limited vocabulary.
So it is very difficult, known by very few people and is rarely taught.
The next level is the Assembly
language, which can be translated word by word into machine language
by an assembler. Assembly language, also called Symbolic language
uses mnemonic code, that are abbreviations that are easy to remember
for instructions, rather than binary. In addition each computer has
its own assembly language, and so there is no common assembly language.
But there are four reasons why computer science majors must learn assembly
language.
1. Assembler works very much
faster than a compiler (used to translate higher level languages).
But it takes a lot longer to write an assembly language. However,
sometimes a few lines of code can take a lot of time to compile. Often
a hybrid language is written in which that part of the code is written
in assembly language, and the rest of the code in the higher language.
Overall this the most efficient, time wise.
2. If the program does not
give accurate results, and desk checking does that locate the problem then
we can ask for a "dump" which prints the contents of memory at any required
instant. This is in machine language, which can easily be translated
into assembly language.
3. Although Assembly language requires
more lines of code, it actually requires less memory to store. There
are situations where memory space is very limited such as credit cards,
heart pace makers, hearing aids, watches, automobile ignition systems,
etc. where there is not enough room for higher-level language code.
4. Assembly language mimics
the way a computer behaves. We can understand how the computer operates,
about pointers, registers, stacks better when using an assembly language.
Assembly language is a window into the soul of a computer.
The first higher level language was FORTRAN,
which
stands for Formula Translator. In the early days when
computers were used for calculation, this was a very useful language.
It still has limited uses in areas where very complicated calculations
such as in Space science, Nuclear Science or in weather forecasting.
But since the primary purposes of computers has changed into storage, communications,
graphics, etc. FORTRAN has lost its importance. It is a unstructured
language and this offended purists who called it "Spaghetti Programming",
because the program jumped from place to place. People who did not
require complex calculations started COBOL, which stands for COmmon
Business
Oriented
Language.
In COBOL there is no need for equations. For instance you can code
Add A to B giving C, instead of C = A + B. But the language is very
verbose. Niklaus Wirth started Pascal, named for French Mathematician
Blaise Pascal to circumvent these problems. Pascal is a structured
language, and though it became popular in academia, industry preferred
FORTRAN for its ease. Algol started at the same time became popular
in Europe but did not catch on in the United States. In the 1970's
when Microcomputers were introduced, a new problem arose. All these
languages required Compilers to translate into Machine Language.
But the microcomputers had insufficient memory for that purpose. (It is
no longer a problem now). So BASIC which stands for Beginners
All purpose Symbolic
Instruction Code, which was
a simplified version of FORTRAN was started at Dartmouth College, with
a compiler small enough to fit into a microcomputer. Another benefit
was that it was a very easy language and thus could be taught in schools,
which rarely ahd main frames. Other languages such as PL1 (Programming
Language One) and APL (Another programming language) did not succeed and
were discarded. These languages (FORTRAN, COBOL, Pascal, and Basic)
are Procedural languages. BASIC was taught by the education department,
FORTRAN by the School of Engineering, COBOL by the Business Division, and
Pascal in the Computer Sciences. These languages are also platform
dependent, that is they have to be recompiled (not rewritten) for a different
computer. Since compilation takes a very long time, this leads to
inefficiency. Bell laboratories started a language which was originally
named B (after
Bell). This language was revised considerably
and renamed C. Originally another procedural language, it was converted
into an Object
Oriented
Language C++.
Smalltalk
is the most object oriented language. C++ and Java
have major elements of Object Orientation. Here the attributes of
a Class are inherited. Java, based largely on C++ is
platform independent. While the other languages are translated into
Machine Language, Java is converted into Byte Codes.
A major advantage of Java is the Internet can be integrated seamlessly
into information systems using Java. Originally, it was to be named
Oak, after an oak tree outside the office window at Sun Microsystem of
its developer, James
Gosling ,
but that name was already taken. The group was discussing the language,
and thinking of a name in a Coffee House, and one of then looked at his
cup and asked, "Why not Java?", and the name struck. Java was promoted
in 1995 as a means of adding dynamic content to Worldwide Web pages.
Instead of web pages with only text and static graphics, using Java, web
pages could come alive with audios, videos, animations, interactivity,
and three dimensional imaging. Java has become the language of choice
for implementing Internet-based and Intranet-based applications and software
for devices that communicate over a network. Java is now used to
create web pages with dynamic and interactive content, to develop large-scale
enterprise applications, to enhance the functionality of World Wide Web
servers, and to provide applications for consumer devices (such as cell
phones, pagers, and personal digital assistants).
Java programs consist of pieces called classes, which consist of pieces called methods, that perform tasks and return information on completion of the tasks. Java class libraries ( also known as Java APIs - Application Programming Interfaces) contain rich collections of existing classes. Class libraries are provided by compiler vendors, by independent software vendors (ISVs), and are also available from the internet and World Wide Web as freeware or shareware, that may be downloaded.
Java programs go through five executable phases, edit, compile, load, verify, and execute. In the edit phase we write a program on "Notepad". Java program filenames end with the .java extension. The command Javac in "Command Prompt" compiles the program. The java compiler translates the Java program into bytecodes, the language understood by the Java interpreter. This creates the .class file. The program is then loaded into memory by the class loader, which takes the .class file(s) containing the bytecodes and transfers it to memory. The two types of programs for which the class loader loads are applications and applets. An application is stored and executed from the user's local computer while the applet is stored on a remote computer that users connect via a World Wide Web browser. Applications are loaded into memory and executed using the Java interpreter (also known as the Java Virtual Machine or JVM) by the command java. The class loader also executes when a World Wide Web browser such as Netscape Navigator or Microsoft Internet Explorer loads a Java Applet. Browsers are used to view documents on the World Wide Web called the Hypertext Markup Language (HTML) documents. HTML describes the format of a document in a manner that is understood by the browser application. The browser launches the Java class loader to load the applet, and the browser's Java interpreter executes the applet. Applets can also execute from the command line using the appletviewer command. Next the bytecodes are verified by the bytecode verifier, to ensure that they are valid and do not violate Java's security restrictions. (Java programs arriving over the network should not damage local files). The computer then interprets the program one bytecode at a time and executes it.
Java is a portable language and can run on many different computers. More information at java.sun.com . A web-based version of the Java API documentation java.sun.com/j2se/1.3/docs/api.index.html This document can be downloaded at java.sun.com/j2se/1.3/docs.html Java programs execute interpretively, and thus slower than fully compiled machine code. But the advantage of an interpreter is that execution can begin immediately as soon as it is downloaded while a source program must be first compiled. The Java compiler javac does not convert a source code into machine code for a particular computer platform, but translates it into bytecodes.
Java is an object oriented Language. Object-Oriennted Design (OOD) provides a more natural and intuitive way to view the design process, by modeling real-world objects, their attributed, their behavior. OOD models communication between objects. OOD encapsulates data (attributes) and functions (behavior) into objects; the data and functions are intimately tied together. Objects have the property of information hiding, that is although they communicate with one another across well defined interfaces, they do not know how other objects are implemented. Implementation details are hidden within the objects themselves. (Like driving a car without know how the engine operates)
Java programmers create their own user-defined types called classes and components. Each class contains data and the set of functions that manipulate that data. The data components of a Java class are called attributes. The function components of a Java class are called methods. An instance of a user-defined type (class) is called an object. Built-in types are the building blocks for constructing user defined types. The focus in Java is on classes (making objects) rather than on functions. Classes are to objects what blueprints are to houses. Just as many houses can be built from the same blueprint, many objects can be instantiated from one class. Classes can have relationships with other classes. Classes can be reused in future software systems. Groups of related classes are packaged as reusable components. Much of the software can be built by combining standardized interchangeable parts called classes. Each new class will have the potential to become a software asset that can be used to speed and enhance the quality of future software development.
Analyzing and designing systems
from an object-oriented point of view is called object-oriented analysis
and design (OOAD) process. A single graphical language
for communicating the result of OOAD process is the Unified
Modeling Language (UML) developed by Grady
Booch, a chief scientist
at Rational Corp., James
Rumbaugh,
a leading software
development methodologist, and Dr. Ivar Jacobson, recently retired as Vice
President of Process Strategy at Rational, founded the Swedish company
Objectory AB, which merged with Rational in 1995. One of the three original
designers of the UML (Unified Modelling Language), he has also made seminal
contributions to software development in: component architecture, software
process, use-case driven development, and business modelling.
It is the most widely used graphical representation scheme for modeling
object-oriented systems. It is flexible, extendable, and independent
of OOAD processes. UML modelers are free to develop systems by using
various processes but with one standard set of notations. It is a
complex feauture-rich graphical language.
For other books by the same authors Deitel
and Deitel
or for the publisher: Prentice-Hall
For interactive CD ROMs etc.: Informit
Java was developed at Sun Microsystems.
For their web site: Sun
Microsystems
There are two ways of programming in Java.
Applications (Chapter 2) and Applets (Chapter 3)
1.
Applications (Chapter 2)
2.
Applets (Chapter 3)