0% found this document useful (0 votes)
24 views17 pages

01-Introduction To Object Technology

The document outlines the fundamentals of object-oriented technology, including the evolution of programming languages, the concepts of objects and classes, and the Java programming language. It discusses the characteristics and applications of object-oriented programming, emphasizing its advantages such as code reusability and adaptability. Additionally, it covers the Java platform, its compiling model, features, and development environment.

Uploaded by

tatuan20052020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views17 pages

01-Introduction To Object Technology

The document outlines the fundamentals of object-oriented technology, including the evolution of programming languages, the concepts of objects and classes, and the Java programming language. It discusses the characteristics and applications of object-oriented programming, emphasizing its advantages such as code reusability and adaptability. Additionally, it covers the Java platform, its compiling model, features, and development environment.

Uploaded by

tatuan20052020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

2

Outline

1. Object-Oriented Technology
OBJECT-ORIENTED LANGUAGE AND THEORY
1. INTRODUCTION TO OBJECT TECHNOLOGY 2. Object and Class
3. Java programming language
4. Examples and Exercises

1 2

3 4

1.1 Evolution of programming languages Assembly


• Assembly language a. Assembly code

• Structure/Procedure programming languages


language
• Pascal, C
• Object programming languages
• C++, Java, C#.NET, Python…

• Is a sequence programming language, is very close to machine codes


of CPU.
• Hard to remember, to write, especially for complex systems.
• Hard to fix bug, to maintain.

3 4

Page 1
1
5 6 6

b. Structure/Procedure programming languages c. Object programming languages

• Build a program based on • Characterizing elements of a problem in form of objects


functions/procedures/sub- • Object-oriented is a technique to model a system by
programs
objects.
• Data and data processing
unit (functions) are
separate
• Functions are not forced to
follow a common rule for
accessing data

5 6

7 8

Evolution of programming languages


Reading exercises
• Is the history and evolution of abstraction • Readand summarize some differences
• Assembly : Abstraction of data type/basic command between struture programming and OOP
• Structure langugues: control abstraction + functional
abstraction [Link]
• OO languages: Data abstraction

7 8

Page 2
2
9 10

What about other programming paradigms? 1.2 Object Technology


• Aspect-Oriented Programming • Object technology is a set of rules
(abstraction, encapsulation,
• Functional Programming polymophism), instructions to
build a software, together with
languages, databases and other
tools to support these rules.

(Object Technology - A Manager’s Guide, Taylor, 1997)

9 10

11 12

1.3 Where is the object technology used? 1.3 Where is the object technology used? (2)

• Client/Server Systems and • Mobile development (Android)


Web development • Embedded system
• Object technology allows • Real-time systems
companies to encapsulate • Object technology allows real-time systems to be developed
information in objects and to with higher quality and in a more flexible way
distribute its • Satellite systems
computation/processing via • Defense systems and space airline … 4

Internet or via a network.

11 12

Page 3
3
13 14

The power of the object technology Milestones of the object technology

• Allow re-using source code and architectures


• Reflecting more closely the real world
Simula C ++ The UML
• More stable, a system change is done in a small
part of the system 1967 Late 1980s 1996

• More adaptable with changes 1972 1991 2004

Smalltalk
Java UML 2

13 14

15 16

Outline Alan Kay’ concepts


1. All are objects.
1. Object-Oriented Technology 2. A software program can be considered
as a set of objects interacting with each
2. Object and Class other
3. An object in a program has its own data
3. Java programming languages and its own memory.
4. An object has all characteristics of its
4. Examples and Exercises class.
5. All objects of a class have the same Alan Kay
behavior

15 16

Page 4
4
17 18

2.1 Object 2.1 What is object?


• Object is the key to • Objects in the real world
understand the • For example, a car
object technology • Related to a car:
• In a OO system, all • Car information such as: color, speed,...
are objects
• Car activities: moving forward, reversing, stopping,...

Writing a OO program means to build


a model of some parts in the real world

17 18

19 20

What is object? What is object?


Tom Car
House • Is an entity encapsulated in form
of state and behavior.
Reality

• State is represented by
Tree
attributes and relationships.
• Behaviour is represented by
Object-oriented modeling
operations and methods.

Model

drives
House Car
lives in
Tree
Tom

19 20

Page 5
5
21 22

State
An object has a state
• The state of an object is one of the possible conditions that
the object exists.
• The state of an object can change over time
Dave
Age: 32
Height: 6’ 2”
Brett
Age: 35
Height: 5’ 10”

Gary
Age: 61
Height: 5’ 8”

21 22

23 24

An object has its behavior Behavior


• Behavior determines how an object acts and reacts to Get the mail.
requests from other objects. Cook dinner.
• Object behavior is represented by the operations that
the object can perform.

23 24

Page 6
6
25 25 26

An object has an unique identity ID


• Each object has its own unique identity, although two
objects may share the same state (attributes and
relationships) Okay, which one of De great Poppini
you wise guys is the I am the great at-a your service.
real Poppini? Poppini.
I am the great
Poppini!
No, I’m the great
I’m the great Poppini.
Poppini!

25 26

27 28

Object Software objects and a real-life problem


Problem of bank account management – ATM – electronic payment

Account name: Duc Binh


Attributes
I’d like to check
Balance: 2.000.000 VND my balance

Actions Deposit Debit Service request

Balance inquiry
Software object Software object Bike Balance inquiry

Software space
Account object
Object is an entity with two Attributes are defined by a User object
name: Duc Binh
key components: specific value called Attributes
Balance: 2.000.000 VND Message passing
attributes and methods. instance attributes.
A specific object is called Actions Deposit() Withdraw() checkBalance()

an instance. checkBalance()

27 28

Page 7
7
29 30

2.2 Class Example: Bike class


Bike class’s representation
• A class is a blueprint or prototype for all the objects of a
same type
• Example: class Bike is a common blueprint for many Objects of XeDap

bike objects that are created


• A class defines common attributes and methods for all the
objects of some type
• An object is a detailed representation of a class.
• Example: a bike object is a representation of the class
Bicycle
• Each object can have different attribute’s representation
• Example: a bike can be at the 5th gear while another bike
can be at the 3rd gear.

29 30

31 32

Class and Object Account object of Mr Duc Binh


Class and Object
Account Class (model of objects)
name: Duc Binh
Attribute
Definition of member variable Balance: 2.000.000 VND

operation Deposit() Withdraw()


Attribute String name; Blueprint/prototype
long balance; checkBalance()

INSTANTIATE
Method definition
Account object of Mrs Thu Lan
Representation
void deposit(int money);
name: Thu Lan
Attribute
Balance: 1.000.000 VND
operation
void withdraw()
operation Deposit() Withdraw()

int checkBalance() checkBalance()

31 32

Page 8
8
33 34

Quick question 2.3 Interactions between objects


• Given the Amazon online shopping system. Provide some • Communication between objects in the real world
examples about class and object in this system?

• The same question for HUST Student Information


System?

• Objects and their interactions in programming


• Objects communicate to each other by message passing

33 34

35 36 36

Message passing 2.4 Structure-Oriented vs. OO?


• A program (built via OOP) is a set of objects exchanging • Structure-Oriented:
messages between them • data structures + algorithms = Program
• Object-Oriented:
• objects + messages = Program

return SS#

35 36

Page 9
9
37 38

Procedural-oriented vs. Object-oriented Examples of class and object in some


• Procedural Programming: OOP languages
• Main components are procedures, functions • Lớp Time trong Java
• Data is independent with procedures

• Object-oriented programming
• Main components are objects
• Data is associated to function (method) in an object
• Each data structure has methods executing on it

37 38

39 40 40

Outline
Java: Program and object
1. Object-Oriented Technology
2. Object and Class
3. Java programming languages
4. Examples and Exercises

39 40

Page 10
10
41 41 42

3.1 What is Java? Java Editions


• Java is a object-oriented • JSE: Java standard edition
programming language • JEE: Java enterprise edition
developped by Sun • JME: Java micro edition
Microsystems, and now • Java Card
bought by Oracle Green Team and James Gosling
• Java is a popular (the leader)

programming language
• Initially used for building control
processor applications inside the
electronics consumer devices
such as cell phones, microwaves
...
• Initially used in 1995

41 42

43 43 44 44

JSE (Java Platform Standard Edition) JEE (Java Platform Enterprise Edition)
• Java Runtime Environment, Standard Edition (JRE): • Service-Oriented Architecture (SOA) and Web services
• Executable Environment or JRE provides Java APIs, • Web Applications
Java Virtual Machine (JVM) and other necessary • Servlet/JSP
components to run applets and applications written in • JSF…
Java. • Enterprise Applications
• Java Software Development Kit, Standard Edition (JDK) • EJB
• Super set of JRE, and contains everything in the JRE, • JavaMail…
additional tools such as compilers and the debugger •…
need to develop applets and applications.

43 44

Page 11
11
45 45 46 46

3.2 Java platform 3.3. Java Compiling model


• Platform is environment for
development of deployment. • a. Classical compiling model:
• Java platform can be run on all • Source code is compiled into binary code.
OSs
%cc Hello.c –o Hello
• Other platforms depend on
hardware % Hello
• Java platform provides: Binary Code
Run
• Java Virtual Machine (JVM).
• Application Programming Interface
(API).

45 46

47 47 48

3.3. Java Compiling model 3.3. Java Compiling model


• b. Compiling model of Java:
• Source code is compiled
into bytecode and then %javac [Link]
javac [Link] java Hello
interpreted by JVM. [Link] created Notepad,vi
% java Hello
Emacs,
Editplus
Source
Run JVM Byte Code Java
Editor code Execution
Compiler

[Link] [Link]

47 48

Page 12
12
49 49 50 50

3.3. Java Compiling model 3.4. Features of Java


• Java Virtual Machine: • Java is designed to be:
• JVM is the heart of Java language • A powerful programming language, full of OO features
• Bring the feature “Write once, run everywhere” and completely OO.
• Provides environment to execute instructions: • Easy to learn, syntax is similar to C++
• Load file .class • Platform independance
• Manage memory
• Support the development of applications in network
• Garbage collections
environment
• The Interpreter “Just In Time - JIT”
• Ideal for Web application
• Transform bytecode to machine code for each type of CPU.

49 50

51 51 52 52

3.4. Features of Java (2) 3.4. Features of Java (3)


• Powerful • Simple
• Class library: Hundreds of classes already written with • Keywords
utility functions. • Java has 50 keywords
• Java uses pointer model without accessing directly to • Compared to Cobol VB that have hundreds of keywords
the memory; memory can not be over-written. • Network capable
• Object-Oriented • Java supports the development of distributed
• Java supports software development by using OO applications
• Some applications of Java are designed in order to be
• Software built in Java includes classes and objects
accessed via Web browser.

51 52

Page 13
13
53 53 54 54

3.4. Features of Java (3) 3.4. Features of Java (5)


• Java has 50 key words • Multi-threaded
• assert (New in 1.5) enum (New in 1.5) • Allows a program to run more than one task at the same
time.
• Portable
• Programs can be written once and run on different
platforms
• Based on compiler/interpreter model
(WORE – Write Once, Run Everywhere)

53 54

55 55 56 56

3.4. Features of Java (6) 3.5. Applications in Java


• Development Environment • Application
• Java Development Kit • Do not need to run on browsers
• Free on Sun Website: [Link] • Can call functions through commands or option menu
• Including: Compiler, JVM and existing classes (GUI)
• Integrated Development Environments (IDEs): Providing: • main() method is the starting point of the program
• Complex Text Editors execution
• Debugging Tools
• Applet
• Graphics Development Tools
• GUI application running on browser in the client side.
• Can be viewed by appletviewer or embedded in Web
browser with JVM installed.

55 56

Page 14
14
57 57 58 58

3.5. Applications in Java (2) Outline


• Web application
• Create dynamic content on Server instead of on 1. Object-Oriented Technology
browsers.
2. Object and Class
• Used in Server application
• Servlet: manage requests from browsers and send the 3. Java programming languages
responses back
• JavaServer Page (JSP): HTML pages with embedded
4. Examples and Exercises
Java code.

57 58

59 59 60 60

Example 1 - HelloWorld Example 1 (Cont.)


// [Link]
• Comment
// Chuong trinh hien thi dong chu “ Hello World ” • In one line: Starts with //
public class HelloWorld { • In multiple lines: /* ... */
/* Phuong thuc main se duoc goi dau tien • Java distinguish between lowercase and uppercase
trong bat cu ung dung Java nao*/ • Keywords in Java:
public static void main(String args[]){ • class: Class definition
[Link]( “ Hello World!" ); • public: Access permission
} // ket thuc phuong thuc main • Class name containing main function must have the same
} // ket thuc lop HelloWorld name with the file .java.

59 60

Page 15
15
61 61 62 62

Installing and Running Java application Environment Variables


• Step 1: Install jdk, install environment variables (if using • PATH = %PATH%;C:\Program Files\Java\jdkx.x\bin
cmd) • JAVA_HOME=C:\Program Files\Java\jdkx.x
• Step 2: Install Eclipse or Netbean IDE
• CLASSPATH = C:\Program
• Step 3: Coding Files\Java\jdkx.x\lib;.;C:\Program
• Step 4: Compile Files\Java\jdkx.x\include
• cmd: javac [Link]
• Eclipse/Netbean: Build automatically (Look at Console
to see syntax errors if any)/F11 (Project) or F9 (File)
• Step 5: Run program
• cmd: java HelloWorld
• Eclipse/Netbean: Run as Java application
(Alt+Shift+X+J)/F6 (Project) or Shift-F6 (File)

61 62

63 63 64 64

Example 2 - GUI Example 3 – Data Input/Output


import [Link];
import [Link]; public class HelloNameDialog{
public class FirstDialog{ public static void main(String[] args){
public static void main(String[] args){ String result;
[Link](null, result = [Link](“Hay nhap
ten ban:”);
”Xin chao ban!”); [Link](null,
[Link](0); ”Xin chao “+ result + “!”);
} [Link](0);
} }
}

63 64

Page 16
16
65 66

Example of Class and Object in Java Java: Program and Objects

• Lớp Time trong Java

65 66

Page 17
17

You might also like