Object Oriented Programming
Object Oriented Programming
TeguhSutanto
Si | STIKOM Surabaya
teguh@stikom.edu|+628563076813|http://teguhsutanto.blogspot.com|http://blog.stikom.edu/teguh
GOAL
1.Students can understand the Object Oriented Programming concepts 2.Students can make a program in accordance with the rules of Object Oriented Programming
Object-oriented programming (OOP) is a programming paradigm using "objects" data structures consisting of data fields and methods together with their interactions to design applications and computer programs
Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data
Why OOP?
1. Object-oriented systems can be easily upgraded from small to large scale. 2. It is easy to partition the work in a project based on objects. 3. Object-oriented programming offers a new and powerful model for writing computer software. 4. It reduces software maintenance and developing costs. 5. Changes in user requirements or later developments have always been a major problem. 6. Object-orientation or object oriented programming (OOP) should help one in developing high quality software easily.
Classes reflect concepts, objects reflect instances that embody those concepts
object class
girl
Jodie
Daria
Jane
Brittany
Attribute/Field/Data
Method
Field Declaration
a type name followed by the field name, and optionally an initialization clause primitive data type vs. Object reference
o
com
Person
name: String address: String # age: int +getName(): String
X
MainMenu
X
Employee
HRD
Pencil.java
public class Pencil { public String color = red; public int length; public float diameter; private float price; public static long nextID = 0; public void setPrice (float newPrice) { price = newPrice; } }
public static void main (String args[]){ Pencil p1 = new Pencil(); p1.price = 0.5f; }
}
%> javac Pencil.java %> javac CreatePencil.java CreatePencil.java:4: price has private access in Pencil p1.price = 0.5f; ^