programming paradigms seminar 2

39
Seminar 2 : The state of the practice Programming Paradigms [The Paradigms - Group 2]

Upload: neoxiuting

Post on 25-Dec-2014

748 views

Category:

Documents


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Programming Paradigms Seminar 2

Seminar 2 : The state of the practice

Programming Paradigms

[The Paradigms - Group 2]

Page 2: Programming Paradigms Seminar 2

2

Most of us will be in I.T Industry

Page 3: Programming Paradigms Seminar 2

3

Being experts in a paradigm can help us climb up the corporate ladder

Architect

Designer

Programmer

Page 4: Programming Paradigms Seminar 2

4

Object-Oriented Paradigm

Page 5: Programming Paradigms Seminar 2

5

Everyone knows how to use Object-Oriented Programming Languages

JAVAC++C# JAVASCRIPT

PHP

Objective-c

Python

Page 6: Programming Paradigms Seminar 2

6

But does knowing

OO programming languages equivalent to knowing

OO paradigm?

Page 7: Programming Paradigms Seminar 2

7

Let us be Experts in OO Paradigm And overcome its limitations

Page 8: Programming Paradigms Seminar 2

Training : OO Characteristics

Skill 1: OO Analysis

Skill 2: OO Design

Skill 3: Overcoming Limitations

Quest: Mastery of OO

Page 9: Programming Paradigms Seminar 2

9

Recap: What is OO Paradigm?

Characteristics of OO

Training : OO Characteristics

Page 10: Programming Paradigms Seminar 2

10

Let’s Recap:What is Object-Oriented Paradigm?

Page 11: Programming Paradigms Seminar 2

11

Recap

Object-Oriented Paradigm

View everything as objects which– Behaviors– Properties

Name:Gender:Size:Eye _colour:Shopping()

Human

Animal

“Alice”

“Bob”

Building

Page 12: Programming Paradigms Seminar 2

12

Abstraction

Encapsulation

Inheritance

PolymorphismCharacteristics of OO

But have you misunderstood any of

these concepts?

OO Characteristics? You know that…

Page 13: Programming Paradigms Seminar 2

13

Scenario: Looking for an item in Challenger

Weak OO Model

Page 14: Programming Paradigms Seminar 2

14Straight OO Modeling

Weak OO Model

Page 15: Programming Paradigms Seminar 2

15

Recap: What is OO Paradigm?

Characteristics of OO

Training : OO Characteristics

Abstraction Encapsulation Inheritance Polymorphism

Page 16: Programming Paradigms Seminar 2

Abstraction: A high level view

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

Eliminate the Irrelevant, Amplify the Essential

Page 17: Programming Paradigms Seminar 2

The Vet Point of View

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

• Relevant•Parts of the cat•Etc…

• Irrelevant•Favorite Toy•Etc…

Page 18: Programming Paradigms Seminar 2

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…

Page 19: Programming Paradigms Seminar 2

Programming Point of View

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

US Keyboard

getAlphabet()getNumeric()getFunction()

ATM Keyboard

getNumeric()getFunction()

Page 20: Programming Paradigms Seminar 2

Encapsulation

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

Hiding the Unnecessary

Page 21: Programming Paradigms Seminar 2

Programming Point of View

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

Student+ StudentID+ CAP

Student- StudentID- CAP

Private Public

Page 22: Programming Paradigms Seminar 2

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

Page 23: Programming Paradigms Seminar 2

23

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

They might look the similar, but they are not.

Father SonModeling the Similarity

Page 24: Programming Paradigms Seminar 2

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

StudentnamegenderaddressphoneNumbermatricNo

driveVehicle()

ProfessornamegenderaddressphoneNumberstaffID

driveVehicle()

What if we have bugs in the algorithm of driveVehicle()?

Programming Point of View

Page 25: Programming Paradigms Seminar 2

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

StudentnamegenderaddressphoneNumbermatrixNo

driveVehicle()

ProfessornamegenderaddressphoneNumberstaffID

driveVehicle()

A Better Solution

Page 26: Programming Paradigms Seminar 2

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

Personnamegenderaddress

driveVehicle()

Base Class

StudentmatricNo

ProfessorstaffID

Derived Class

(Generalization)

(Specialization)

Inheritance is used to express “is a” relationship.

Page 27: Programming Paradigms Seminar 2

27

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

If you ask different animal to “speak”, they responds in their own way.

Same Function Different Behavior

Page 28: Programming Paradigms Seminar 2

Characteristics of OO

28

Abstraction Encapsulation Inheritance Polymorphism

computeSalary()

accountant.computeSalary() CEO. computeSalary() programmer. computeSalary()

computeSalary() computeSalary()

Programming Point of View

Page 29: Programming Paradigms Seminar 2

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()

Page 30: Programming Paradigms Seminar 2

Characteristics of OOAbstraction Encapsulation Inheritance Polymorphism

We can use Inheritance to apply polymorphism.

Employee

computeSalary ()

computeSalary() computeSalary() computeSalary()

Employee object = new CEO();

object.computeSalary();

Page 31: Programming Paradigms Seminar 2

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 ()

Page 32: Programming Paradigms Seminar 2

32

OO CharacteristicsAbstraction“Eliminate the Irrelevant,

Amplify the Essential”

Encapsulation“Hiding the Unnecessary”

Inheritance“Modeling the Similarity”

Polymorphism“Same Function Different Behavior”

Page 33: Programming Paradigms Seminar 2

Strong OO ModelReinforce weak OO model with 4 characteristics.

Page 34: Programming Paradigms Seminar 2

Strong OO ModelAbstraction

• Abstract only relevant information for Multimedia Class

Page 35: Programming Paradigms Seminar 2

Strong OO ModelEncapsulation

• Protect attributes from any direct access

Page 36: Programming Paradigms Seminar 2

Strong OO ModelInheritance

• Extend Multimedia class to more than one class with specialized functionalities

Page 37: Programming Paradigms Seminar 2

Strong OO ModelPolymorphism

• Apply polymorphism for common method with different implementation

Page 38: Programming Paradigms Seminar 2

Training : OO Characteristics

Skill 1: OO Analysis

Skill 2: OO Design

Skill 3: Overcoming Limitations

Quest: Mastery of OO

Page 39: Programming Paradigms Seminar 2

Thank you!

End of Presentation