1 Introduction to Object-Oriented
Design
1
Objectives
At the end of the lesson, the student should be able to:
• Familiarize with programming terminologies
• Describe procedural and object-oriented programming
concepts
• Describe the features of the Java programming language
2
Learning About
Programming
• Program
• Set of written instructions that tells computer what to do
• Machine language
• Most basic circuitry-level language
• Low-level programming language
3
Learning About
Programming (cont'd.)
• High-level programming language
• Allows you to use vocabulary of reasonable terms
• Syntax
• Rules of language
• Program statements
• Similar to English sentences
• Carry out tasks of program
4
Learning About
Programming (cont'd.)
• Compiler or interpreter
• Translates language statements into machine code
• Syntax error
• Misuse of language
• Misspelled programming language word
• Debugging
• Freeing program of all errors
• Logic errors
• Also called semantic errors
• Incorrect order or procedure
5
Procedural vs. Object-
Oriented Programming
• Procedural programming
• Sets of operations executed in sequence
• Variables
• Named computer memory locations that hold values
• Procedures
• Individual operations grouped into logical units
• Object-oriented programs
• Create classes
• Create objects from classes
• Create applications
6
Procedural vs. Object-
Oriented Programming
• Object-oriented programming was used most frequently for
two major types of applications
• Computer simulations
• Graphical user interfaces (GUIs)
• Not all object-orientated programs written to use GUI
• Object-oriented programming differs from traditional
procedural programming
• Basic concepts
• Polymorphism
• Inheritance
• Encapsulation
7
Understanding Classes,
Objects, and Encapsulation
• Class
• Describes objects with common properties
• Definition
• Instance
• Objects
• Specific, concrete instance of a class
• Attributes
• Characteristics that define object
• Differentiate objects of same class
• Value of attributes is object’s state
8
Understanding Classes,
Objects, and Encapsulation
9
Understanding Classes,
Objects, and Encapsulation
• Method
• Self-contained block of program code
• Similar to procedure
• Encapsulation
• Refers to hiding of data and methods within object
• Provides security
• Keeps data and methods safe from inadvertent changes
10
Understanding Inheritance
and Polymorphism
• Inheritance
• Important feature of object-oriented programs
• Classes share attributes and methods of existing classes but with
more specific features
• Helps you understand real-world objects
• Polymorphism
• Means “many forms”
• Allows same word to be interpreted correctly in different situations
based on context
11
Features of the Java
Programming Language
• Java
• Developed by Sun Microsystems
• Object-oriented language
• General-purpose
• Advantages
• Security features
• Architecturally neutral
12
Features of the Java
Programming Language
• Java (cont'd.)
(cont'd.)
• Can be run on wide variety of computers
• Does not execute instructions on computer directly
• Runs on hypothetical computer known as Java virtual machine (JVM)
• Source code
• Programming statements written in high-level programming language
13
Features of the Java
Programming Language
• Bytecode
(cont'd.)
• Statements saved in file
• Java compiler converts source code into binary program
• Java interpreter
• Checks bytecode and communicates with operating system
• Executes bytecode instructions line by line within Java virtual
machine
14
Features of the Java
Programming Language
(cont'd.)
15
Java Program Types
• Applets
• Programs embedded in Web page
• Java applications
• Called Java stand-alone programs
• Console applications
• Support character output
• Windowed applications
• Menus
• Toolbars
• Dialog boxes
16
Summary
l Programming Terminologies
l Procedural Programming vs. Object-oriented Programming
l Understanding classes, objects, and encapsulation
l Understanding inheritance, polymorphism
l Features of the Java Programming language
Reference:
Farrell, Joyce (2012). Java Programming 6th Edition
17