Introduction
Introduction
Data Structures and Abstract Data Types (ADTs). How to organize data.What is object oriented programming?
Why object oriented programming?
Why Java?
A few words about programming languages
A programming language is a modeling tool. We use it to describe things, systems, processes in the real world. We use abstraction to capture the essential aspects of the systems and processes in the language.A programming language is a language for writing algorithms. An algorithm is a step-by-step procedure used to produce some desired result. (Think of a recipe for baking chocolate chip cookies.) The language is inherently limited by the capabilities of the computing machine on which it will be executed. Each computer has a primitive machine language. We use a high level programming language (like Java C++ Scheme Cobol Fortran etc.) to simplify the programming process. Programming is simplified by the use of a higher level of abstraction. These are also called problem oriented languages.
Basic elements of procedural programming
Basic data typesinteger
floating point
character
boolean
Constants and variables
Statements
Control structures
if-then-else
while
Procedures and functions
Structured data types
arrays
structures
pointers
Object-oriented programming
Procedural view: A program is an algorithm (i.e., a step-by-step procedure) for solving some problem.Object-oriented view: A program is a set of interacting objects, which communicate by sending messages to each other.
The objective is still the same (we want to solve a problem), but the focus is different. Objects are used to model entities in the problem domain; for example, numbers, data files, GUI components, people, colleges, automobiles, soda machines, countries, etc. etc. etc.
The messages sent between objects are requests to perform some action. An object responds to such a request by executing a method, which is essentially a procedure, and then possibly sending a result back to the requestor. This form of interaction is typically identified as the client-server model. The requesting object is the client; it sends a request for service to a server object, which performs the service and sends a reply back to the client.
An object may act as both a client and a server within the same program. That is, it may respond to requests from some objects, but it may also rely on the services of other objects to carry out its methods.
Some examples:
Print server on a network
Class scheduler at a college
Database server
In an interactive program, the user is the ultimate client. When the program starts up, various objects are created. The user makes requests to these objects by using the keyboard and mouse.
So, why object oriented programming?
Problem: Today's applications require lots of code. They keep getting bigger all the time. 75% of programming time is spent on maintenance. Writing all that code costs time and money. How can all this code be organized and managed? How can it be made efficient and reliable?
Promote reusability. Reusability has been an objective of language designers since the earliest programming languages, through subroutines, macros, procedures, and functions. But the object orientated programming paradigm has been more successful at achieving it.
Promote a higher level of abstraction. (through inheritance)
Promote modularity. (through encapsulation and composition)
Need to break large problems down into smaller ones.
Successful at implementing Abstract Data Types. The Java API contains implementations of many common ADTs, such as List, Map, etc.
Why Java?
- Java was designed from scratch for object-oriented programming.
Everything is an object (almost).
- One feature of Java is strong data typing. Each object has a data type; Java has strict rules concerning data types. As a result, programs tend to be less error-prone, and errors are more easily detected by the compiler.
- There is no pointer data type. Instead, Java uses references , which are transparent to the programmer.
- Java is platform-independent.