Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
163 views

01-1-Introduction To Object Technology

1. The document introduces object-oriented programming and object technology. It discusses the progression from machine code and assembly languages to procedural and object-oriented programming paradigms. 2. Object technology is defined as a set of rules like abstraction, encapsulation, and polymorphism that are used to build software using languages, databases, and other tools that support these rules. 3. Key benefits of object technology discussed include reflecting real world models more closely, facilitating reuse, and being adaptive to change. Major milestones in the development of object technology are also outlined.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

01-1-Introduction To Object Technology

1. The document introduces object-oriented programming and object technology. It discusses the progression from machine code and assembly languages to procedural and object-oriented programming paradigms. 2. Object technology is defined as a set of rules like abstraction, encapsulation, and polymorphism that are used to build software using languages, databases, and other tools that support these rules. 3. Key benefits of object technology discussed include reflecting real world models more closely, facilitating reuse, and being adaptive to change. Major milestones in the development of object technology are also outlined.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1-Introduction to Oabject Technology

2 2

Outline

1. Programming Paradigm
OBJECT-ORIENTED PROGRAMMING
1.1 INTRODUCTION TO OBJECT TECHNOLOGY 2. Object Technology
3. Java
Nguyen Thi Thu Trang
trangntt@soict.hust.edu.vn 4. Exercises

1 2

3 3 4

Programming paradigm
1.1. Assembly
code
• Machine code Machine
• Assembly language
Code
• Procedural programming languages
• COBOL, FORTRAN, BASIC, Pascal, C
• Assembly language
• Object programming languages • Is a sequence programming language, is very close to
• C++, Java, C#.NET, Python machine codes of CPU.
• Hard to remember, to write, especially for complex
systems.
• Hard to fix, to maintain.

3 4

Page 1
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 1
1-Introduction to Oabject Technology

5 5 6 6

1.2. Procedural Languages 1.3. Object-Oriented Programming


• Proceduralor structural • Programming implementation
programming focuses technique based on objects
mainly on writing software • Software engineering best
based on functions practice
• Data and functions that
• The use of objects allow systems to
manipulate data are kept
become extensible, scalable,
separate maintainable and adaptable
• Proceduralprograms • Closely represent objects of the
cannot easily enforce a real world, keeping the
common way to access programmer in touch with the
data problem

5 6

7 7 8 8

Outline Object Technology


• Object technology is a set of
1. Programming Paradigm rules (e.g. abstraction,
2. Object Technology encapsulation,
polymophism), instructions
3. Java to build a software, together
4. Exercises with languages, databases
and other tools to support
these rules.
(Object Technology - A Manager’s Guide, Taylor, 1997)

7 8

Page 2
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 2
1-Introduction to Oabject Technology

The Strengths of Object Technology The History of Object Technology


• Reflects a single paradigm • Major object technology milestones
• Facilitates architectural and code reuse
• Reflects real world models more closely
Simula C ++ UML Python 3
• Encourages stability
• Is adaptive to change 1967 Late 1980s 1996 2008

1972 1991 2004

Smalltalk Java, UML 2


Python

9 10

Where Is Object Technology Used? Where Is Object Technology Used? (2)


• Client/Server Systems
• Real-time systems
and Web Development
• Object technology enables real-time
• Object technology
systems to be developed with higher
allows companies to
quality and flexibility.
encapsulate business
information in objects 4

and helps to distribute


processing across the
Internet or a network.

11 12

Page 3
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 3
1-Introduction to Oabject Technology

13 14 14

Object-Oriented Programming What is an Object?


Tom Car
House
• Object is the key
to understand the Reality

object technology Tree

• In a OO system,
all are objects Object-Oriented Modeling

Model

drives
House Car
lives in
Writing a OO program means to build Tree

a model of some parts in the real world Tom

13 14

16 16

What is an Object? Attributes


Interactions between objects
• Communication between objects in the real world
• An object is an entity with a
well-defined boundary and
identity that encapsulates
state and behavior.
• State is represented by
attributes and relationships. • Objects and their interactions in programming
• Behavior is represented by • Objects communicate to each other by message passing
operations, methods, and state Object
machines. Operations

15 16

Page 4
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 4
1-Introduction to Oabject Technology

17

Software objects and a real-life problem What Is a Class?


Problem of bank account management –ATM ther – electronic payment

Account name: Duc Binh • A classis a description of a set of objects that


Attributes
Balance: 2.000.000 VND
I’d like to check
my balance share the same attributes, operations, relationships,
and semantics.
Actions Deposit Debit Service request
• An object is an instance of a class.
Balance inquiry
Balance inquiry • A class is an abstraction in that it
Software space • Emphasizes relevant characteristics.
Account object
User object • Suppresses other characteristics.
Attributes
name: Duc Binh Class
Balance: 2.000.000 VND Message passing
+ attribute
+ operation()
Actions Deposit() Withdraw() checkBalance()

checkBalance()

17 18

19 20 20

Class and Object Account object of Mr Duc Binh


Structural vs. OO Programming
Account Class (model of objects) • Structural Programming
name: Duc Binh
Definition of member variable
Attribute
Balance: 2.000.000 VND
• data structures + algorithms = Program
• Object-Oriented:
operation Deposit() Withdraw()
Attribute String name; • objects + messages = Program
long balance; checkBalance()

INSTANTIATE
Method definition
Account object of Mrs Thu Lan

void deposit(int money);


name: Thu Lan
Attribute
Balance: 1.000.000 VND
operation
void withdraw()
operation Deposit() Withdraw()

int checkBalance() checkBalance()

19 20

Page 5
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 5
1-Introduction to Oabject Technology

21 22 22

Procedural vs. Object-Oriented Programming Outline


• Procedural Programming:
• Main components are procedures, functions 1. Programming Paradigm
• Data is independent with procedures
2. Object Technology
• Object-Oriented Programming 3. Java
• Main components are objects
• Data is associated to function (method) in an object
4. Exercises
• Each data structure has methods executing on it

21 22

23 23 24 24

3.1 What is Java? Java SE (Java Platform Standard Edition)


• Java is a object-oriented • https://www.oracle.com/java/technologies/java-
programming language
se-glance.html
developped by Sun
Microsystems, and now • Former name: J2SE
bought by Oracle
• Develop and deploy Java applications
• Java is a popular Green Team and James Gosling
(the leader)
programming language on desktops and servers
• Initially used for building control
processor applications inside the
electronics consumer devices
such as cell phones, microwaves
...
• Initially used in 1995

23 24

Page 6
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 6
1-Introduction to Oabject Technology

25 26 26

JRE and JDK Java EE (Java Platform Enterprise Edition)


• Java SE Runtime Environment (JRE) • https://www.oracle.com/java/technologies/java-
• Executable Environment or JRE provides Java APIs, ee-glance.html
Java Virtual Machine (JVM) and other necessary
• Former name: J2EE. New name (from 2020)
components to run applets and applications written in
Java. • Extending Java SE with specifications for
• Java SE Development Kit (JDK) enterprise features such as distributed
• Super set of JRE, and contains everything in the JRE, computing and web services
additional tools such as compilers and the debugger • Web Applications: Servlet/JSP, JSF…
need to develop applets and applications. • Enterprise Applications: EJB, JavaMail…

25 26

27 28 28

Java ME (Java Platform Micro Edition) 3.2 Java platform


• https://www.oracle.com/java/technologies/javame • Platform is environment
overview.html for development of
deployment.
• Applications running on embedded and mobile
• Java platform can be run
devices in the Internet of Things
on all OSs
• Micro-controllers, sensors, gateways,
• Other platforms depend on
• Mobile phones, personal digital assistants (PDAs), hardware
• TV set-top boxes, printers • Java platform provides:
• Java Virtual Machine (JVM).
• Application Programming
Interface (API).

27 28

Page 7
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 7
1-Introduction to Oabject Technology

29 29 30 30

3.3. Compiling model of Java 3.3. Compiling model of Java (2)


• b. Compiling model of Java:
• a. Classical compiling model: • Source code is compiled
• Source code is compiled into binary code. into bytecode and then %javac Hello.java

interpreted by JVM. Hello.class created


%cc Hello.c –o Hello % java Hello

% Hello
Run JVM Byte Code
Run Binary Code

29 30

31 32 32

Development procedure of Java Applications 3.3. Compiling Model of Java (3)


• Java Virtual Machine:
• JVM is the heart of Java language
javac Hello.java java Hello • Bring the feature “Write once, run everywhere”
Notepad,vi
• Provides environment to execute instructions:
Emacs,
Editplus • Load file .class
Source
Java
• Manage memory
Editor code Execution
Compiler • Garbage collections
• The Interpreter “Just In Time - JIT”
Hello.java Hello.class
• Transform bytecode to machine code for each type of CPU.

31 32

Page 8
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 8
1-Introduction to Oabject Technology

33 33 34 34

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


• Java is designed to be: • Powerful
• Class library: Hundreds of classes already written with
• A powerful programming language, full of OO
utility functions.
features and completely OO. • Java uses pointer model without accessing directly to
• Easy to learn, syntax is similar to C++ the memory; memory can not be over-written.
• Platform independance • Object-Oriented

• Support the development of applications in • Java supports software development by using OO

network environment • Software built in Java includes classes and objects

• Ideal for Web application

33 34

35 35 36 36

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


• Simple • Java has 50 key words
• assert (New in 1.5) enum (New in 1.5)
• Keywords
• Java has 50 keywords
• Compared to Cobol VB that have hundreds of keywords
• Network capable
• Java supports the development of distributed
applications
• Some applications of Java are designed in order
to be accessed via Web browser.

35 36

Page 9
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 9
1-Introduction to Oabject Technology

37 37 38 38

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


• Multi-threaded • Development Environment
• Allows a program to run more than one • Java Development Kit
task at the same time. • Free on Sun Website: java.sun.com
• Including: Compiler, JVM and existing classes
• Portable
• Integrated Development Environments (IDEs):
• Programs can be written once and run on Providing:
different platforms • Complex Text Editors

• Based on compiler/interpreter model • Debugging Tools


• Graphics Development Tools
(WORE – Write Once, Run Everywhere)

37 38

39 39 40 40

3.5. Applications in Java 3.5. Applications in Java (2)


• Application
• Web application
• Do not need to run on browsers
• Can call functions through commands or option menu • Create dynamic content on Server instead of on
(GUI) browsers.
• main() method is the starting point of the program • Used in Server application
execution
• Applet • Servlet: manage requests from browsers and
• GUI application running on browser in the client side. send the responses back
• Can be viewed by appletviewer or embedded in Web • JavaServer Page (JSP): HTML pages with
browser with JVM installed. embedded Java code.

39 40

Page 10
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 10
1-Introduction to Oabject Technology

41 41 42 42

Outline Example 1 - HelloWorld


// HelloWorld.java
public class HelloWorld {
1. Object-Oriented Technology /* The main() method will be called first in any
2. Object and Class Java applications */
public static void main(String args[]){
3. Java programming languages System.out.println( “Hello World!" );
}
4. Examples and Exercises }

41 42

43 43 44 44

Example 1 (Cont.) Installing and Running Java application


• Comment • Step 1: Install jdk, install environment variables (if using
• In one line: Starts with //
cmd)
• Step 2: Install Eclipse or Netbean IDE
• In multiple lines: /* ... */
• Step 3: Coding
• Java distinguish between lowercase and
• Step 4: Compile
uppercase
• cmd: javac HelloWorld.java
• Keywords in Java:
• Eclipse/Netbean: Build automatically (Look at Console
• class: Class definition to see syntax errors if any)/F11 (Project) or F9 (File)
• public: Access permission • Step 5: Run program
• Class name containing main function must have • cmd: java HelloWorld
the same name with the file .java. • Eclipse/Netbean: Run as Java application
(Alt+Shift+X+J)/F6 (Project) or Shift-F6 (File)

43 44

Page 11
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 11
1-Introduction to Oabject Technology

45 45 46 46

Environment Variables Example 2 - GUI


• PATH = %PATH%;C:\Program Files\Java\jdkx.x\bin
• JAVA_HOME=C:\Program Files\Java\jdkx.x import javax.swing.JOptionPane;
• CLASSPATH = C:\Program public class FirstDialog{
Files\Java\jdkx.x\lib;.;C:\Program public static void main(String[] args){
Files\Java\jdkx.x\include
JOptionPane.showMessageDialog(null,
”Xin chao ban!”);
System.exit(0);
}
}

45 46

47 47

Example 3 – Data Input/Output


import javax.swing.JOptionPane;
public class HelloNameDialog{
public static void main(String[] args){
String result;
result = JOptionPane.showInputDialog(“Hay nhap
ten ban:”);
JOptionPane.showMessageDialog(null,
”Xin chao “+ result + “!”);
System.exit(0);
}
}

47

Page 12
@NGUYỄN Thị Thu Trang, trangntt@soict.hust.edu.vn 12

You might also like