Vietnam National University of HCMC
International University
School of Computer Science and Engineering
Object Oriented Programming
(IT069)
Nguyen Trung Ky, PhD
📧 ntky@hcmiu.edu.vn
1
Object Oriented Programming
● Instructor and Lab Tutor: Dr. Nguyen Trung Ky.
Ph.D. Grenoble Alpes University 2019; second year at IU.
Research on Computational Linguistics (Natural Language Processing,
Natural Language Generation) and Machine Learning.
Office: O1.610
Ask immediately after class or by appointment via email
ntky@hcmiu.edu.vn
● Prerequisite courses: C/C++ programming
● Course credit: 4
○ Lecture: 3 (start from 21/09/2023 – 11/01/2024)
○ Laboratory: 1 (start from 17/10/2023 – 19/12/2024)
2
Learning outcomes
1. Analyze a problem and design an object oriented solution
2. Apply an object oriented solution in JAVA/C++/C# programming language
3. Explain concepts of object oriented programming
- Classes.
- Methods.
- Objects.
- Encapsulation.
- Information Hiding.
- Polymorphism.
- Inheritance.
- Abstraction.
4
Topics to be covered in this course
1. Introduction to Object Oriented concepts 10. Generic collection
2. A quick tour of Java 11. Object Oriented design principles: SOLID
3. How to think in terms of objects - S: Single responsibility
- O: Open/closed principle
4. Classes and objects - L: Lisko substitution principle
5. Inheritance and composition - I: Interface segregation principle
- D: Dependency inversion principle
6. Polymorphism
12. Reusing Designs Through Design Patterns
7. Design with interfaces and abstract classes
- Singleton
8. Building Objects - Observer
9. Generic classes and methods - Strategy
5
Materials/Books
Textbooks
- Paul J. Deitel ( Harvey Deitel (Author), Java How To
Program, 9th Edition, Prentice Hall, 2011
References
- Matt Weisfeld , The Object Oriented Thought
Process , 3rd Edition, Addison Wesley, 2009
- Erich Gamma, Richard Helm, Ralph Johnson and
John Vlissides , Design Patterns: Elements of
Reusable Object Oriented Software , Addison
Wesley Professional, 1994
- Eric Freeman, Bert Bates, Kathy Sierra and
Elisabeth Robson, Head First Design Patterns: A
Brain-Friendly Guide, O'Reilly Media, 2004
- https://martinfowler.com/ 6
Blackboard
● Course information, announcements
○ IT069IU_1_2023-2405: Object-Oriented Programming_S1_2023-24_G05 (KyNguyen)
● Lectures
● Upload lab assignments, quizzes
7
Grading policies
1. Quizzes and Labs or Project: 30%
2. Midterm: 30%
3. Final: 40%
8
Project
Create a game in a team 3-4 students.
For examples:
- Plants vs Zombies
- Candy crush
- Monopoly
- Mario
Task
- Read and present the game rules
- Design classes
- Implement the game with basic rules (50pts)
- Write report (10pts) – game rules, class diagrams, …
- Demonstration (10tps)
- Use Git (10pts) – Commits history
- Implement a graphical user interface (10pts)
Bonus
- Extra features (+2pts for each)
- Apply design patterns (+5pts for each) 9
Grading policies
Please share your
opinion on practical
work using code
38268806 on
menti.com or the
following QR code
10
Agenda
- What are Programming Paradigms?
- What is Object Oriented Programming (OOP) ?
- Why should we learn Java?
- What are JDK, JRE, JVM? How these works together?
11
Introduction to
Object Oriented Programming
12
Programming Paradigms
- Different approaches to build solutions to specific problems.
- Most programming languages belong to one paradigm.
- Two most popular programming paradigms:
- Procedural Programming
- Object-Oriented Programming
13
Procedural Programming
VS
Object Oriented Programming (OOP)?
14
Procedural Programming
- Step-by-step approach to break down a task into a set of variables and
sequences of transformations using functions.
- Data and functions are separated.
15
Procedural Programming Example
Data A Data B
Function 1 Function 2 Function 3
Function 4 Function 5
Output
16
Problems for Procedural Programming
- Hundreds of functions.
- How to manage: Sort them in alphabetical order?
- Hundreds of global variable can be accessed or must not to be accessed
by many different functions.
- How to make sure there is no unintended modifications?
- Not secure, because there is not any proper way for hiding data or limit access of
specific data.
Not easy to scale up for large and complex applications
Therefore, Object-oriented programming helps to address these
issues
17
What is Object-Oriented Programming (OOP)?
18
Object-Oriented Programming (OOP)
- Software design focuses around data or objects.
- The program is divided into small parts called objects (basic unit).
- Object is an entity that contains attributes (data) and methods (behaviors).
- Objects knows how to perform certain actions and how to interact with other objects
of the program.
Example: a person has:
- Attributes (data): eye colors, heights, …
- Methods (behavior): walking, talking, ...
Object Object
Send message
Attribute (Invokes) Attribute
Method Method Method Method Method Method
19
OOP Example Object Y
Object X
Attribute B
Attribute A
Method
2
Method 1 Method 3
Method 4
Output Method 5
20
Procedural Programming Object-Oriented Programing
21
Why we choose to learn Java for OOPs?
22
Java
- Java is one of the most popular languages in the world.
- Run on 15 billion devices
- Used by 12 million developers
- Beginner Friendly
- Large Community
- Excellent Document Support
- Many big tech companies used Java as their back-end systems
23
https://www.oracle.com/java/moved-by-java/timeline/
Java is still the king of job market in Vietnam
Attractive Salaries in Vietnam
The most popular language at work in Vietnam
(Vietnam Developer Report 2019)
24
Nearly 1 out of every 5 IT jobs is Java
25
Java Software and Version
27
What are JDK, JRE, JVM ?
- Java Development Kit (JDK)
- Tools to develop and create Java programs (on Windows, MacOS and Linux)
- Contains:
- Debuggers for testing code or find errors.
- Java Compiler to compile the source code into Java bytecode.
- Java Runtime Environment (JRE)
- Including libraries to run and execute the Java bytecode.
- Does not include any developing tools.
- Including a specific Java Virtual Machine (JVM)
- Runs Java bytecode on that specific platform.
- Different platforms requires different JVM.
28
How Java works
Windows
Developers JVM
Java Runtime MacOS
develops (JDK) Environment JVM
(JRE)
Runs
Java source compile (JDK) Java class files
(*.class) - Java JVM Linux
files (*.java) 29
bytecode
Platform Independent Platform Dependent
=> Java is cross platform - “Write once, run everywhere!”
Which Java Development Kit (JDK) to use?
- A new version is released at every six months.
- So only go for Long Term Support (LTS) Versions.
- History of JDK:
- JDK 11 (09/2018) - LTS till 2026
- JDK 12 (03/2019)
- JDK 13 (09/2019)
- JDK 14 (03/2020)
- …
- JDK 17 (09/2021) - LTS till 2029 (Recommended)
- 4 Big Vendors (Companies) produces their own JDK using same version number:
- Oracle
- Amazon
- IBM
- Redhat
30
https://www.oracle.com/java/technologies/java-se-support-roadmap.html
To start developing,
- The best JDK is the JDK 17 (LTS).
- JDK usually includes JRE. Thus, only install JDK is good enough.
- JDK vendor is not important. Let’s stick with Oracle JDK!
- For the editor/IDEs, IntelliJ IDEA is very beginner friendly!
31
https://www.oracle.com/java/technologies/downloads/
Recap
This lecture, we have learnt about:
- Programming Paradigms.
- Basic idea of Object Oriented Programming (OOP).
- The importance of Java.
- The differences between JDK, JRE, JVM and how these works together.
32
Thank you for your listening!
33