java tutor oo ps introduction-version 1
DESCRIPTION
TRANSCRIPT
Object oriented programming
Presented byUday Sharma
Presenting Object oriented Programming (Java) and aspects of management of project.
1
2
Why this tutorial?
To gain knowledge of Object Oriented ProgrammingWhy this tutorial for java why not for C++?• Aim to do practice on Object Oriented programming and
understanding of basic needs to be a programmer• Knowing C++ or Java will not make us a programmer but
understanding of project, project requirement , project management are really important • Company demand force you to work on different technology• Right platform to learn something new what we do not know
3
Java developers and general software developers in permanent roles get an average salary of between €42,000 and €60,000 per year in 2012. This compares to an average salary of €40,000 to €55,000 in 2011.However, in London, Java developers managed to get an average salary of between €66,000 and €107,000, while in Sydney, they could get salaries of between €73,000 and €105,000.
Why java ?• Open source package•Wastly useful in Web technology• Java Embedded technology • Client / Server application • Graphical user interface• Design patterns • Test-driven development APIs
Why this tutorial?
4
After Student life
CVObjectiv: bla bla –Study : bla bla– Programming language : C, C++Project work :
Java
Interview
5
What is object – oriented?
State(Variable)
Entity (Methods)
Name BarkingColor PlayBreed SlobberHungry Biting
Asian countryNo money
GermanyMoneyrains
Barking
Biting
Object Properties
6
Why object oriented necessary ?
Ballpen
Parts/Objects/Member of ballpen
12 3
4
5
6 7
7
Properties of Parts/Objects/Member
Part 1 Part 2 Part 3 Part 4 Part 5 Part 6Name Name Name Name Name NameColor Color Color Upper-
Color Ink- Color
Size Size Size Size Size SizeGrip Grip Grip Grip Grip GripNotch Notch
SizeNotch Notch
Shape Shape Round Shape
Shape Shape
Why object oriented necessary ?
1
2
3
4 6
7
5
8
Object oriented programming types
• Java• C#• .Net• PHP• Python• C++• Lisp• Ruby on Rain• Objective- C• Matlab• Lisp
9
Real time example of OOPsConcept
Name, Shape,
grip,Diameter
2 3
5
6
7
1
Class Ballpen
Sub Class of class Ballpen
Name, Shape, color, grip, Diameter..
Name, Shape,
grip, Diameter
Nam
e,
Shap
eDi
ame
ter.
Sub Class of class Ballpen
Sub Class of class Ballpen
Class of class 2
Sub class of class 1
Member of Class 6, Class 7, Class 1, Class 2
Ballpen
S.Class 1
S.Class 3
S.Class 2
S.Class 5
S.Class 6
Class 7.
Inheritance
Name, shape,color and grip, Diameter
Encapsulation
Sun Rise Ltd
Sun Rise Ltd
Sun Rise Ltd.
Name,
Sh
ape,
co
lor,
gr
ip,
Diam
eter
..
10
Interview question
• What is an Object in OOPS?
• What is an Attribute in OOPs?
• What is a Entity in OOPS?
• What is an Identity in OOPS?
• What is Encapsulation in OOPS?
• What is Inheritance in OOPS?
• What is Polymorphism in OOPS?
• What is Compile Time Polymorphism in OOPS?
• What is Run Time Polymorphism in OOPS?
• What is Access Modifier in OOPS?
11
• Project have a purpose• Project are realistic• Project have duration• Project are complex• Project are collective• Project are unique• Project are adventure• Project can be assessed• Project are made up of stages
Characteristic of project?
12
OOP: model, map, reusability, extention
DataMethodMethod
DataMethodMethod
DataMethodMethod
Object
Object Object
• Model the real worldproblem to user’sperceive
• Use similar metaphorin computational env.Construct reusablecomponents
• Create newcomponents fromexisting ones
13
Examples of objects
14
Classes: Objects with the same attribute and behavior
Person Object
Abstract into
Person ClassAttributes: Name, Age, SexMethod :Speak(), Listen(), Walk()
Abstract into
Vehicle ClassAttributes: Name, Model, CarMethod :Start(), Stop(), Accelerator()
Vehicle Object
Abstract into
Polygon ClassAttributes: Vertices, border, color, FillcolorMethod :Draw(), Erase(), Move()
Polygon Object
15
Object Oriented Paradigm
Encapsulation
Data Abstration
Single Inheritance
Polymorphysm
Persistance
Delegation
Genericity
Multiple Inheritance
OOP Paradigm
16
Encapsulation
Encapsulation
Data Abstration
Single Inheritance
Polymorphysm
Persistance
Delegation
Genericity
Multiple Inheritance
OOP Paradigm
It associates the code and the data it manipulates into a single unit and keeps them safe from external interference and misuse
17
Data Abstraction
Encapsulation
Data Abstration
Single Inheritance
Polymorphysm
Persistance
Delegation
Genericity
Multiple Inheritance
OOP Paradigm
• The technique of creating new data types that are well suited to an application• It allows the creation of user defined data types, having the properties of built data types and a set of permitted operators• In Java, partial support• In C++, fully supported (e.g., operator overloading)
18
Abstract Data Type
• A structure that contains both data and the actions to be performed on that data
• Class is an implementation of an Abstract Data Type
19
Class
class Account {
//Attributes of account.private String accountName;private double accountBalance;
//Entity of account.public withdraw();public deposit();public determineBalance();} / / Class Account
Class is a set of attributes and operations that are performed on the attributes.
Account
+accountName+accountBalance
+withdraw();+deposit();+determineBal();
20
Access Modifier
Private :Protected:Public:
Private: Drinking beer
Protected: Drinking beer
Public: Drinking beer
21
Exercise
Car --- Create class for carBird --- Create class for Bird
22
Solution for car
Car- hasNumberPlate- hasNoDoors
+ setDoors()+setRoof()+setGlass()+setHeadlight()+setWheel()
BMW
- hasType- hasName- hasColor- hasEngineType- hasShape
+ setDoors(hasshape,hasNoDoors)+setRoof(hasshape)+setGlass(hasShape)+setHeadlight(hasShape)+setWheel(hasShape)+setEngine()
23
Bird Example
24
Bird- hasHeight- hasWidth
+ setEye()+setLeg()+setWing()+setThroat()+setNape()+setBack()+setBill()+setTail
Parrot
- hasType- hasName- hasbackColor,wingscolor....- hasHeight- hasWidth- hasShape
+ setWing(hasColor)+setLeg(hasShape)+setWing(wingcolor)+setBill(hasShape)+setTail(hasShape)
Solution for bird
25
Inheritance
• New data types (classes) can be defined as extensions to previously defined types
• Parent Class (Super Class) – Child Class (Sub Class)• Subclass inherits properties from the parent class
Parent
Child
Inherited Capability
26
Inheritance-Example
• Example• Define Person to be a class• A Person has attributes, such as age, height, gender• Assign values to attributes when describing object
• Define student to be a subclass of Person• A student has all attributes of Person, plus attributes of
his/her own ( student no, course_enrolled)• A student has all attributes of Person, plus attributes of
his/her own (student no, course_enrolled)
• Define lecturer to be a subclass of Person• Lecturer has all attributes of Person, plus attributes of
His/her own ( staff_id, subjectID1, subjectID2)
27
Inheritance- Example
Circle Class can be a subclass (inherited from ) of a parent class - Shape
28
References
• [<Project Management> <Youth partnership> <Page> http://youth-partnership-eu.coe.int/youth-partnership/documents/Publications/T_kits/3/2_project.pdf >]