Professional Documents
Culture Documents
Object-Oriented Programming Concepts
Object-Oriented Programming Concepts
Object-Oriented Programming Concepts
Programming
for Beginners
Instructor: Aung Hein
HELLO!
I am Aung Hein
Bachelor of Computer Science (UCSY)
Cyber Security & Quantum Computing
Enthusiasts
2
Python Programming for
Beiginners
0 . Fundamentals of Python
1. Object Oriented Programming Concepts
3. Design Pattern
6. Web Scraping
7. Automation &Testing
3
1 Object-Oriented Programming
Concepts
Why Object-Oriented Design?
7
What is Class?
Object
Class Object
Object
8
Class Component
9
Dog
life-span
colour
sleep()
eat()
run()
Class
10
Dog
life-span 12 years 13 years
colour white brown
Class object(instance)
creating objects = instantiation 11
Fundamentals of OOP for creating classes
⬢ Abstraction
⬢ Polymorphism
⬢ Inheritance
⬢ Encapsulation
12
Abstraction
⬢ You would think male or female or someone you know might appear in
your mind when we tell you a person.
13
Abstraction (Cont’d )
Person
name
height
flavour
icing
sleep()
eat()
run()
14
Encapsulation
⬢ Restrict access to some of the object’s components
15
Encapsulation (Cont’d )
Cookie Jar
numCookie 10
16
Encapsulation (Cont’d )
Cookie Jar
numCookie 10
requestCookie()
requestCookie()
17
Inheritance
⬢ Base a new object or class on an existing one
⬢ Inherit the existing attributes and methods
⬢ Great form of code reuse!
18
Inheritance (Cont’d )
Customer Employee
name name
phone phone
address address
customerNumber employeeNumber
updateContact() updateContact()
purchase() promote()
retire()
19
Inheritance (Cont’d )
Customer Employee
name name
phone phone
address address
customerNumber employeeNumber
updateContact() updateContact()
purchase() promote()
retire()
20
Inheritance (Cont’d )
Person
name Superclass
(Parent class)
phone
(Base class)
“Customer inherits from Person” address
updateContact()
Customer Employee
Subclass
(Everything in (Everything in
(Child class)
Person) Person)
(Derived class)
customerID employeeID
purchase() purchase()
21
retire()
Inheritance (Cont’d )
Child Child
22
Polymorphism
⬢ Use the same interface for methods on different types of objects
⬢ brew(groundCoffee, water)
23
Polymorphism (Cont’d )
BasicCoffeeMaker
size
brew()
pour()
FrenchPress
(Everything in BasicCoffeeMaker)
Overriding
brew()
24
“
Object-oriented
25
“
Object-oriented
26
“
Object-oriented
27
“
Object-oriented
Programming – Build it
28
Requirements
Requirements = What does it need to do?
• Functional requirements = What must it do?
• Non-functional requirements = How should it do?
29
Functional requirements
What must it do?
30
Non-functional requirements
How should it do?
• Legal
• Performance
• Support
• Security
31
FURPS Requirements
⬢ Functionality => Capability, Reusability, Security
⬢ Usability => Human Factors, Consistency, Documentation
⬢ Reliability => Availability, Failure Rate & Duration, Predictability
⬢ Performance => Speed, Efficiency, Scalability
⬢ Supportability => Extensibility, Configurability, Testability
32
Let’s challenge your understanding
• Please think and write down the requirements of any systems you can think
about.
33
Use Cases
⬢ What the actor must do or how they accomplish a particular goal?
⬢ For this we are going to capture that is use cases
⬢ 3 things for use cases:
⬢ Title -> describes a goal
⬢ Person -> who will achieve that goal
⬢ Scenario -> the steps to complete the goal
34
Use Cases
Edit Content
Admin
Add Comment
Blogger
35
Let’s challenge your understanding
• Write two use cases:
1. Title
2. Primary actor
3. Scenario
36
Abstract Class
⬢ Exists for other classes to inherit
⬢ Cannot be instantiated
⬢ Contains at least one abstract method
37
Abstract Class (Cont’d )
Spaceship
Abstract class Spaceship { …
setShield()
move()
fireMissle() dropCargo()
38
Interface
⬢ List of methods for a class to implement.
⬢ It doesn’t contain any actual behaivour.
39
Interface (Cont’d )
<<interface>>
Movable
move()
Spaceship Asteroid
setshield() move()
move() detectCollision
Shuttle
move()
dropCargo()
40
Aggregation
Fleet
…
1
0..*
Spaceship
…
41
Composition
Spaceship
…
1 1
1..* 0..*
Engine Shield Weapon
… … …
42
Let’s challenge your understanding
• Inheritance
• Interfaces
• Aggregation
• Composition
43
THANKS!
You can find me at:
⬢ https://www.facebook.com/mgsein123
⬢ aunghein116688@gmail.com
⬢ 095120779
44