Post on 25-Dec-2014
description
Seminar 2 : The state of the practice
Programming Paradigms
[The Paradigms - Group 2]
2
Most of us will be in I.T Industry
3
Being experts in a paradigm can help us climb up the corporate ladder
Architect
Designer
Programmer
4
Object-Oriented Paradigm
5
Everyone knows how to use Object-Oriented Programming Languages
JAVAC++C# JAVASCRIPT
PHP
Objective-c
Python
6
But does knowing
OO programming languages equivalent to knowing
OO paradigm?
7
Let us be Experts in OO Paradigm And overcome its limitations
Training : OO Characteristics
Skill 1: OO Analysis
Skill 2: OO Design
Skill 3: Overcoming Limitations
Quest: Mastery of OO
9
Recap: What is OO Paradigm?
Characteristics of OO
Training : OO Characteristics
10
Let’s Recap:What is Object-Oriented Paradigm?
11
Recap
Object-Oriented Paradigm
View everything as objects which– Behaviors– Properties
Name:Gender:Size:Eye _colour:Shopping()
Human
Animal
“Alice”
“Bob”
Building
12
Abstraction
Encapsulation
Inheritance
PolymorphismCharacteristics of OO
But have you misunderstood any of
these concepts?
OO Characteristics? You know that…
13
Scenario: Looking for an item in Challenger
Weak OO Model
14Straight OO Modeling
Weak OO Model
15
Recap: What is OO Paradigm?
Characteristics of OO
Training : OO Characteristics
Abstraction Encapsulation Inheritance Polymorphism
Abstraction: A high level view
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
Eliminate the Irrelevant, Amplify the Essential
The Vet Point of View
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
• Relevant•Parts of the cat•Etc…
• Irrelevant•Favorite Toy•Etc…
The Owner Point of View
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
• Relevant•Favorite Toy•Etc…
• Irrelevant•Scientific Names of the cat’s body parts•Etc…
Programming Point of View
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
US Keyboard
getAlphabet()getNumeric()getFunction()
ATM Keyboard
getNumeric()getFunction()
Encapsulation
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
Hiding the Unnecessary
Programming Point of View
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
Student+ StudentID+ CAP
Student- StudentID- CAP
Private Public
Programming Point of View
Main Concepts of OOAbstraction Encapsulation Inheritance Polymorphism
Student+ StudentID+ CAP
Public
•Drawbacks• Bypass checking• Breach integrity• Break in code when
there is change • Vulnerable to malicious
attack
23
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
They might look the similar, but they are not.
Father SonModeling the Similarity
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
StudentnamegenderaddressphoneNumbermatricNo
driveVehicle()
ProfessornamegenderaddressphoneNumberstaffID
driveVehicle()
What if we have bugs in the algorithm of driveVehicle()?
Programming Point of View
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
StudentnamegenderaddressphoneNumbermatrixNo
driveVehicle()
ProfessornamegenderaddressphoneNumberstaffID
driveVehicle()
A Better Solution
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
Personnamegenderaddress
driveVehicle()
Base Class
StudentmatricNo
…
ProfessorstaffID
…
Derived Class
(Generalization)
(Specialization)
Inheritance is used to express “is a” relationship.
27
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
If you ask different animal to “speak”, they responds in their own way.
Same Function Different Behavior
Characteristics of OO
28
Abstraction Encapsulation Inheritance Polymorphism
computeSalary()
accountant.computeSalary() CEO. computeSalary() programmer. computeSalary()
computeSalary() computeSalary()
Programming Point of View
29
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
Polymorphism treats each instance of different classes the same way within a system.
Employee.computeSalary()
computeSalary() computeSalary() computeSalary()
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
We can use Inheritance to apply polymorphism.
Employee
computeSalary ()
computeSalary() computeSalary() computeSalary()
Employee object = new CEO();
object.computeSalary();
Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism
computeSalary() computeSalary() computeSalary()
Polymorphism reduce development effort with the help of dynamic binding property.
//people is a list that contains some Accountant, CEO and Programmer objects.
for (Employee p :people){ p.computeSalary();}
Employee
computeSalary ()
32
OO CharacteristicsAbstraction“Eliminate the Irrelevant,
Amplify the Essential”
Encapsulation“Hiding the Unnecessary”
Inheritance“Modeling the Similarity”
Polymorphism“Same Function Different Behavior”
Strong OO ModelReinforce weak OO model with 4 characteristics.
Strong OO ModelAbstraction
• Abstract only relevant information for Multimedia Class
Strong OO ModelEncapsulation
• Protect attributes from any direct access
Strong OO ModelInheritance
• Extend Multimedia class to more than one class with specialized functionalities
Strong OO ModelPolymorphism
• Apply polymorphism for common method with different implementation
Training : OO Characteristics
Skill 1: OO Analysis
Skill 2: OO Design
Skill 3: Overcoming Limitations
Quest: Mastery of OO
Thank you!
End of Presentation