Sie sind auf Seite 1von 27

INTRODUCTION TO JAVA &

OBJECT-ORIENTED
PROGRAMMING
fundamentals of object-oriented programming

WHAT IS A COMPUTER?
COMPUTER
an electronic device for storing and processing data
according to instructions given to it in a variable program.

BASIC COMPONENTS OF A COMPUTER SYSTEM

INPUT

PROCESSOR

MEMORY

OUTPUT

COMPUTER PROGRAMS
PROGRAM
a list of instructions that can be interpreted by a computer
that embodies an algorithm in computer-coded version

ALGORITHM
a procedure or formula for solving a problem

HOW DO WE WRITE
COMPUTER PROGRAMS?

COMPUTER PROGRAMMING
ELECTRONIC COMPUTERS HAVE INSTRUCTION SETS
basic operations that the computer can do
i.e., Turing Machine: MOVE head, READ, and WRITE

MACHINE LANGUAGES
the most primitive (baseline) language that we can use to write programs
machine language is messy and error-prone for humans

DEVELOPMENT OF HIGHER LEVEL


LANGUAGES
assembly language
higher natural programming languages

COMPUTER PROGRAMMING
HIGHER LEVEL PROGRAMMING LANGUAGES
instructions are human readable
programming platforms come with compiler and/or translators

DEVELOPMENTS IN PROGRAMMING LANGUAGES


technology advancements in computers
complexity of problems being solved
developments in compiler design

COME UP WITH DIFFERENT


PROGRAMMING PARADIGMS

PROGRAMMING PARADIGMS
STRUCTURED
top-down design; algorithmic
perspective; procedure,
function, or subroutine

FUNCTIONAL
treats computation as the
evaluation of mathematical
functions

LOGIC
declarative; uses
mathematical logic

OBJECT-ORIENTED
programs are treated as
objects that may be composed
of smaller objects

PROGRAMMING PARADIGMS
THE PROGRAMMING PARADIGM
DICTATES:
HOW YOU SHOULD APPROACH A PROBLEM

HOW YOU SHOULD TREAT ENTITIES IN THE PROBLEM


HOW YOU WRITE YOUR CODE
HOW YOU ARRANGE YOUR CODE

OBJECT ORIENTED PROG.


PROGRAMMING USING OBJECTS
METHOD OF IMPLEMENTATION
programs are organized as cooperative collections of objects
each of which represents an instance of a class
and whose classes are all members of a hierarchy of classes united via
inheritance relationships

WHAT MAKES AN OBJECT?

OBJECT ORIENTED PROG.


CHARACTERISTICS OF AN
OBJECT
AN OBJECT HAS IDENTITY
AN OBJECT HAS STATE
AN OBJECT HAS BEHAVIOR

OBJECT ORIENTED PROG.


SOFTWARE OBJECTS
SOFTWARE OBJECTS HAVE IDENTITY
each is a separate chunk of memory

SOFTWARE OBJECTS HAVE STATE


some of the memory that makes a software object is used for variables
which contains values

SOFTWARE OBJECTS HAVE BEHAVIOR


some of the memory that makes a software object is used to contain
programs that enable the object to do things

OBJECT ORIENTED PROG.


MAIN CONCEPTS IN
OBJECT ORIENTATION
ABSTRACTION
ENCAPSULATION
MODULARITY
HIERARCHY

TYPING, CONCURRENCY, AND PERSISTENCE

BIT OF HISTORY
SIMULATION LANGUAGE (SIMULA)
introduced object-oriented programming concepts such as object, class,
dynamic binding, etc

Ole-Johann Dahl and Kristen Nygaard


Fathers of Object Technology
Creators of Simula I and Simula 67

BIT OF HISTORY
ALAN KAY
(1970s) - led a team that developed
Smalltalk at Xerox PARC
coined the term object-oriented
programming

SMALLTALK
inspired by SIMULA
graphics-driven
used in Dynabook

BIT OF HISTORY
BJARNE STROUSTRUP
implemented C with Classes aka C++
C++ became the most widely used objectoriented language

JAMES GOSLING
1990s his team at Sun developed Java
Java rode with the popularity of the
Internet
simplified C++

OTHER OOP LANGUAGES


NOTABLE OBJECT-ORIENTED
LANGUAGES
EIFFEL

PYTHON

OBJECTIVE-C

RUBY

MODULA-2

CLOS

OBERON

THE VISUAL LANGUAGES

CRITERIA FOR OOPL


ABSTRACTION
supports objects that are data abstractions with interface
of named operations and hidden local state

ENCAPSULATION
objects have an associated type (class)

INHERITANCE
types (classes) may inherit attributes from supertypes
(superclasses)

OBJECT BASED LANGUAGES


ALSO USES OBJECTS
PROGRAMMERS USE BUILT-IN OBJECTS AND MAY NOT
CREATE NEW OBJECT TYPES
USED IN SPECIALIZED ENVIRONMENTS (DATABASES,
GAME ENGINES, ETC.)
CANNOT DO INHERITANCE

VISUALBASIC, JAVASCRIPT,
TYPESCRIPT, ETC.

TYPES OF OOPL
CLASS-BASED
makes use of class to define
objects

PURE
all data types are objects

PROTOTYPEBASED
define a prototype which
becomes the basis for new
objects

HYBRID
mix of primitives and objects

JAVA
JAVA PROGRAMMING LANGUAGE
originally developed by Sun Microsystems, which was
initiated by James Gosling

WHY CHOOSE JAVA?


OBJECT ORIENTED
in Java, everything is an object easily extended since it is based on the Object model

EASY TO USE

SECURE

the fundamentals of Java came from C++

probably the most secure programming


language to date

RELIABLE
Java needed to reduce the likelihood of
fatal errors from programmer mistakes

PLATFORM INDEPENDENT
Java was written to be a portable language

OBJECT
an entity with well-defined boundary that encapsulates
state and behavior anything with which we store data
and the operations that manipulate those data

PROPERTIES OF OBJECTS
OBJECTS HAVE STATES
OBJECTS EXHIBIT BEHAVIOR
OBJECTS HAVE IDENTITY
OBJECTS HAVE RELATIONSHIPS WITH OTHER OBJECTS

OBJECT
STATE
the state of an object encompasses all the properties of the
object and the current values of each of these properties

NEW

CONTINUING

GRADUATING

GRADUATE

PROBATIONARY

DISMISSED

READMITTED

PERMANENTLY
DISMISSED

OBJECT
BEHAVIOR
how an object acts and reacts, in terms of its state
changes and message passing

OPERATIONS
defined actions of objects
aka methods
aka message (i.e., defined messages that objects respond to or understand)

OBJECT
IDENTITY
every occurrence of a particular type of object can be distinguished
from every other occurrence of the same type of object, as well as
object from other types

RELATIONSHIPS
KINDS OF RELATIONS
association
aggregation
inheritance (superclass subclass)

OBJECT
ABSTRACTION
denotes the essential characteristics of an object that distinguish it
from all other kinds of objects and provide a crisply-defined
conceptual boundary, relative to the perspective of the viewer

STUDENT REGISTRATION
SYSTEM
STUDENT

COURSE

RECOMMENDED
COURSE
SECTION

SLOT

LIBRARY PC USAGE
TRACKING
STUDENT

BAN LIST

USER ACTIVITY

CLASS
a structure that contains data and methods that
manipulate those data

TYPES OF CLASSES
CONCRETE CLASS
a set of entities with well-defined
attributes and behaviors

ENTITY/DATA CLASS
objects encapsulate the data used
in a system

ABSTRACT CLASS
a generalized class of objects where
some of its behaviors are left undefined

UTILITY CLASS
maintain utility methods and usually
not instantiatable

CONTROL CLASS & INTERFACE

CLASS
WHAT IS INSIDE
A CLASS?
ATTRIBUTES OF THE OBJECTS THAT BELONG TO
THE CLASS
METHODS REPRESENTING THE BEHAVIORS OF THE
OBJECTS THAT BELONG TO THE CLASS
list of messages that objects of the class respond to

SPECIALIZED METHODS
constructors
destructors

UML CLASS DIAGRAM


UNIFIED MODELING LANGUGE
(UML)
a standard language for specifying, visualizing, constructing, and
documenting artifacts of software systems

CLASS DIAGRAM
describes the attributes and operations of a class (also the constraints)
shows a collection of: classes, interfaces, associations, and collaborations

HOW TO DRAW A CLASS DIAGRAM


name of the class diagram should be meaningful to describe the aspect of the system
each element and their relationships should be identified in advance
for each class, minimum number of properties should be specified

Das könnte Ihnen auch gefallen