Escolar Documentos
Profissional Documentos
Cultura Documentos
Inheritance Pol#morphism and d#namic binding $a%a an example of an object-oriented programming language
OOP: Introduction
OOP: Introduction
social securit# number -cpr.4 emplo#ee number4 passport number hungr#4 sad4 drun/4 running4 ali%e eat4 drin/4 +a%e4 smile4 /iss
beha%ior -methods.
OOP: Introduction
Example 1:
OOP: Introduction
send message
Outside +orld
n object
?ono4 ,iggo $ensen2 Example ): &ard 8a#@s Aight4 $oshua *ree4 Bic/ie Cee $ones2
>
OOP: Introduction
*he text files +e create contain classes= Etatic 9One: class contains a 9receipe: on ho+ to ma/e objects 8#namic 9Man#:
Ingrediens )7F g digesti%e biscuits food processor 1)7 g soft bro+n sugar saucepan 1)7 g butter +ooden spoon 7F g raisins 1D cm sand+ich tin -greased. 1 tablespoons cocoa po+der fridge 1 egg4 beaten /nife )7 g G 1 o" )27 cm G 1 inch Process blend ba/e
source http:''+++2filflora2com
OOP: Introduction
Instantiating Classes
n instantiation is a mechanism +here objects are created from a class2 l+a#s in%ol%es storage allocation for the object2 mechanism +here objects are gi%en an initial state2 Dynamic Instantiating In the method part of a program2 d#namic instance is created explicitl# +ith a special command2
Static Instantiating In the declaration part of a program2 static instance is implicitl# created
OOP: Introduction
1F
O1 and O) must be related to communicate2 *he call of a method corresponds to a function -or procedure.
call in a non-object-oriented language such as C or Pascal2
O1
message
OOP: Introduction
message
O)
message
11
O1
an object
concept is a generali"ation4 deri%ed from a set of phenomena and based on the common properties of these phenomena2
a class
Characteristics of a concept
name Intension4 the set of properties of the phenomenon E tension4 the set of phenomena co%ered b# the concept2
OOP: Introduction
1)
numbers: +ords:
dinosaur: mammal:
OOP: Introduction
11
Concept
classification exemplification
Phenomenon
OOP: Introduction
15
Concept
decomposition
Concept
OOP: Introduction
1;
OOP: Introduction
1>
Concept C
generali$ation
Concept 8
Etation car
1D
OOP: Introduction
1I
OOP: Introduction
)F
OOP: Introduction
)1
OOP: Introduction
))
$oid doSomething('ectangle r)* r.draw()+ r.resi%e()+ 1 $oid doSomething(Square s)* s.draw()+ s.resi%e()+ 1
method bod#
OOP: Introduction
)5
2.3rog.cpp
&istor# of $a%a
1IIF Oa/ -interacti%e tele%ision4 big failure. 1II5 $a%a -for the Internet.
Main feature: L<rite Once4 Bun n# <hereL GM +rap the operating s#stem so the# all loo/ the same fresh start -no bac/+ard compatibilit#. 9Pure: OOP: C(( E#ntax4 Emalltal/ st#le Impro%ements o%er C(( much harder to +rite a bad program Internet programming
8esigned for
,er# hard to create a %irus Bun in a +eb bro+ser -and at the ser%er.
*here is a speed issue -from $a%a 121 and up much better. Canguage %er# similar to $a%a Commen-Canguage Buntime -CCB. supports 1F( languages
)>
!arbage collection
Error and exception handling handling Ao global %ariables or methods Ao local static %ariables Ao separation of declaration and implementation
Ao explicit pointer operations -uses references. Ao preprocessor -but something similar. &as fe+er 9dar/ corners: &as a much larger standard librar# -$a%a 8e%eloper Nit or $8N. OOP: Introduction
)D
Eummar#
Classes are 9recipes: for creating objects ll objects are instances of classes Encapsulation
Ne# feature of object-oriented programming Eeparation of interface from implementation It is not possible to access the hidden'encapsulated parts of an object
OOP: Introduction
)I
OOP: Introduction
11
OOP: Introduction
1)