Course Java programming thinking in Java
Overview
What’s Inside
Preface
1: Introduction to objects
2: Everything is an object
3: Controlling program flow
4: Initialization & cleanup
5: Hiding the implementation
6: Reusing classes
7: Polymorphism
8: Holding your objects
9: Error handling with exceptions
10: The Java IO system
11: Run-time type identification
12: Passing and returning objects
13: Creating windows & applets
14: Multiple threads
15: Network programming
16: Design patterns
17: Projects
A: Using non-Java code
B: Comparing C++ and Java
C: Java programming guidelines
D: A bit about garbage collection
E: Recommended reading
Index
1: Introduction to objects
Why has object-oriented programming had such a sweeping impact on the software development community?
Object-oriented programming appeals at multiple levels. For managers it promises faster and cheaper development and maintenance. For analysts and designers the modeling process becomes simpler and produces a clear, manageable design. For programmers the elegance and clarity of the object model and the power of object-oriented tools and libraries makes programming a much more pleasant task, and programmers experience an increase in productivity. Everybody wins, it would seem.
The progress of abstraction
All programming languages provide abstractions. It can be argued that the complexity of the problems you can solve is directly related to the kind and quality of abstraction. By “kind” I mean: what is it you are abstracting? Assembly language is a small abstraction of the underlying machine. Many so-called “imperative” languages that followed (like FORTRAN, BASIC, and C) were abstractions of assembly language. These languages are big improvements over assembly language, but their primary abstraction still requires you to think in terms of the structure of the computer rather than the structure of the problem you are trying to solve. The programmer is required to establish the association between the machine model (in the “solution space”) and the model of the problem that is actually being solved (in the “problem space”). The effort required to perform this mapping, and the fact that it is extrinsic to the programming language, produces programs that are difficult to write and expensive to maintain, and as a side effect created the entire “programming methods” industry.
An object has an interface
Aristotle was probably the first to begin a careful study of the concept of type. He was known to speak of “the class of fishes and the class of birds.” The concept that all objects,while being unique, are also part of a set of objects that have characteristics and behaviors in common was directly used in the first object-oriented language, Simula-67, with its fundamental keyword classthat introduces a new type into a program (thus classand type are often used synonymously 3).
The hidden implementation
It is helpful to break up the playing field into class creators(those who create new data types) and client programmers 4 (the class consumers who use the data types in their applications). The goal of the client programmer is to collect a toolbox full of classes to use for rapid application development. The goal of the class creator is to build a class that exposes only what’s necessary to the client programmer, and keeps everything else hidden.
Inheritance:reusing the interface
By itself, the concept of an object is a very convenient tool, since it allows you to package data and functionality together by concept, so you can represent an appropriate probleme space idea rather than being forced to use the idioms of the underlying machine. In addition, these concepts are expressed in the primary idea of the programming language: as a data type (using the classkeyword).
Course Java programming thinking in Java (2,66 Mo) (Cours PDF)