0 ratings0% found this document useful (0 votes) 25 views9 pagesPps Notes 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Unit LE ao)
Object Oriented Programming a
J J J
mis
- ae sp)
Programming Paractigqens pod _ 2 a
= Monolithic. a SL
= Procedural he vie pet LL
[= Structured and ri
| = onject oviented
| Features of Object _¢
Ne pest a
|
Classes and _Objecks_t — Lu
- : - i
_ |= class method and self object t
class variables ond object vasiables 1
_ public ond private members » te
- class methods
‘Scanned with ACE ScannerBregreanming_Paredgrn |
con be. defined _os a _methed of ‘problem: +-
| and an _cpproach_to_programoing Sonqua =
design
ving
Various preg ramming poradiqnm ore —
\. Monelithic ptaqromming
2. Procedural programming
[Siee,
Simebyre ef mone tthie
3. Struchurad pragrau mig
‘ f soarareins,
4. Object Oriented _progyameing
Advantages t=
1. Monolithic Programmi ng
\ Easy ds implement prageams Gyr smal |
aeplicutions
contains
TThe_preqyaan _ahich
single funchion: fox the. Jorge prose
| Disadvantc ges
is called monvlithie program.
= Tn_monolithic program “hoy divided the preqram.
\. Difficult to check erroy if the proqram size is
it 18 Yuge lone
gieces of code that dump back
Verne.
ond forth deing all the tasks. Dla. wud te single Rurctinalily , the progroan is.
= This clype of programming consists ef ‘cult ig malotain.
| sequential ede an Joba” cata B_Aindina big beccmes eomplex.
__| +The progr contre) 1s achieved thycu: | ty. Code “con met be yensed 96 it ig nevenally
the use of jumps. fer shat ‘acto" alalements are | wvithen for specific _peblem
used. ee
= No concept of subroutine , $0_preqrany cade ig | 2.Precedural Programming, +
dpi ad each time. A pregeam consists
fas Reet og page [ef _cequence of sidemasia fle erent
q ce ng io BASIC. “Tech | shclement the, values axe stored tn the
Scanned with ACE Scanner= The contro) flow can be altered using + jump",
|__!cal, 'qoto" instructions:
2. Shuictucal | Pregram ming © _
= Theis alse kesue
| +—Fenhure’s ore voriables. assignanent statements | 25 modular foqgiam ming The_stouclured_progrevs
- ond _ikexatios = mainly -coasists” of thre 4ypes ef daments
= Fx _ce50l ECR TRAN. Ligdackion statements _ 7
1 2. Sequence statement: Goo
Treraticn statement -
[Gates cor \ “ESE consists of we drudwred and sept.
—— mockles. _
+ = Uses single snby and singe eit element
> 1 is Th _ ell Maintained and clean.
Subprogiami] [Subprsam2 | [aarcarans J... i ~ Ex: 7G, Pagead - —
| Smuthire of Proudual Prewnmwing | _
: s [@icbal Bata]
- feces Vee
Advontages: = —
t | Ti
Simple and easy to «ite E i TY =H
[2 these languages hove low memory ubilizaten. modules feudea | module
aa Shuclure ef Shuctural “Programming |
Disodvontages +
|| = Large’ complex problems cannst_be imelemented. |
__|_= Porallel_pro mina is folate LL in
|| = Less productive ondvot Jevel_compared to \. Pr easy o implement. |
az | a jo maintain.
other _progyamming Sony Agee ¢ 2. Fasy to main ~ —-|
= Me code. reusability. pire peagenind- on problem based a
| [- Giana) deta can be altered mistaken ed
[= nicast 40 intain_ Pro Saw
fo _j
I] Ls eh
Scanned with ACE Scanner— _____—___-
[ Disadvantages te
\: Development of preqrams toke to: time.
[o. As the programs axe. maihine independent r
| the conversion of programs to machine cede __
provide:
Lobstrat cata “ype tn” which seme.
of the Implementation detalis can be hidden
p—}__takes_time —__|__and_pretected!
— - —— - | 2. Moclifuing the cede far maintenance bexerne
[a object Griented programming = asy.. dis Wy weds In ty guegyem Talia
- in Sne module con mot distush the vest of
= Tn Ais language. eventing i medeled os the cede 4
object, Hente the name Oh. Finding bigs become _enty
= This Jonauage hag 0 mocdsloe programm! - S. Tk provides geod framework fer code_bilbran
‘approach “in “hich dala and fanchiens sre. From which athe seftsare compenents can be:
pound_io ene ently called class.
= More populos because ef its charadecisties
Such ag dala abstraction , encapsulation
inheritance, pelymerphism and sb en.
= Er, Smalltalk, C44 , Java, Python.
Object 4
[Member Funckeo|
A
I
Data |
obj
co
used ond medified by the programmer. |
casily
Disodventeges *
ye
!
can pot be, I
1. Semeimes veal world chiect:
teed easily. Hance it is complex 40 implements
ef athe “members (dala es methods } of —
© the class ave hidden. Hence they- can ost be _
[ace the, chjects of ether cla.
ing f tothe firm of
3. Tn _cep_evezythi gerange: p
classes and idles. Fer the lower level
—ceplications ik _ig net destroble Fealuve-
Ten \ ae a a ag Hs
fonction ft Dato t_ofterted prearammieg opproos
| Member ee
function
wuckure of Object Oriented Proarammins
Scanned with ACE Scanner| progr
__| = Tr is declared using
| Ex class vehicle i
| Objects.
{| = Ae ebject_is an Instance ep a class:
L] + enjects ose ountime entities ef the Cops.
co
Ane_keysord ‘class. 2
1 Evers class enosists ef data members and
1 snebyed s.
NO object senice
__for_on chjut “is a reqest_mode for excustion =
methed for _cbtoiaing the service.
=A message iS a Fequest to an cbjeck te imoke
tne_cf 18 meined. x message thesvfore
= The name ef the mated and
The _orguments of the_mahed. _
des some Ames
—Toheri tance
nheritante ig a _psopecky by
b_the_new classes _ore_ crested ssieg tn i
iecdeelged alle using
“ef eld classes
"The old closses ove veferred as tase closses
Lie eds mesic with each other_using and tha neo classes ove referred as decived
1 | me: Whi municating sith each classes +
1 ther it Ta not neces fo knew the deals = That_means the dedved classes icheve the
1 Of communicabing -ebject™ l — properties (dato and funsions) of bose class.
| =—thus the: inte:nal details of each ebject = This allows to yeuse the existing propeckes ¢F
{ can be hidden fren cncthee object: bose class in derived clo: 2 bs
‘_| Methods and Meseag Passing 1 Srape - -
at a draw {
t (ese |
L Message (request) ||
[sending Receiving
[object J criect Grcle Tine Rectangle.
~ Message (ESPEN SE ateety drowd) arent)
7 ae) Fes
Ths ahjet resae0) reset
ntains seme
- mahed
Communicalinn behoeen koe ebjeds. 7
Scanned with ACE Scanner“[Ragensepbiem = ——f
_|- Polumerphisn means many structures.
take mere than ———=>TBt_child_closs ichesits seme
—___porent class
Sumorphism is the obilil
3 [potent form_ond_refers_to_e0_apesakian ————_. = Mene for the child dass itis :
[| exit i soca 0 Silene to write the cede for the ishedted tehavi
[= The behoviour depends on the type of doto used : written in porent class.
| io the opemtion. Sk plays an inportants ele 19 : For instance the closs Shudent (chats the.
{_ ctlowing objects with “different internal
instanced ( situabons)
i.e, the child clogs disectly used “the medheds
Person class. -_—_..,
= Hence the metheds such ag qeNamet),
struthures to shore the some external ioterface
[= object ‘oriented picgrams use _pelymorghism | gtAddressc) of parent class “Pecson can he
to" corny _eut_the Some operation io a manner __ I direly used bu the Student class.
tustomized to the object: = The _Slodent class can have it can additions!
= Withbut _ pol. mosphisn you woud have to ereate method such ag getMorksi}.
Seperate module names for each method = Thus in ebjet eviented programming melinady |
|: "Tk is an obility of object _oniented es agar thab = « ee ne oe cn gd
Lone class contain the chiets cf one or
more other Plosees. :
TV cceount dless.
= Thig_feahise ollows reusability” of the cole.
a ncther bu evenzif the porent_cless fs et | |
can be writes once and can be stused
Containershie
Delegation |
chare if which ene class depends
“his-ig the ff
poo the thes class ||
__]=ae is represented _by hos a scdeticnship:
jar to confainership» Sub there ves o |
we behaeen the hoo: ti
Consider hoo classes - Customer & Accounts,
The cvstomee class can contain the objects a
ad Beecatan Ga Go naan] ~The child cannot exist 7 vent
= This_is also caUled composi f 5 In compesitien a parent,
a ie i See oingestien oS it _sontains, Na net present. Theat means existence of
congher class in ore clos. : s5_{_fat_present.—Thet_meaes estat Stet
pase
child class sclely depends upen the parent class.
-_ Te ig a strong reakonship. Tl
— In deleqahon there_is dependenuy of one class 0
e_contodnership js denotéd bu hag a relakon,
|
present the dependent class exists. }
— — TO
Scanned with ACE Scanner| tation details
2 class is an enkiiy us
4 _abstracken purpose.
of the system.
= Encapsulation mean:
+The data _insicle_
The methods ove Shonda
= [> hus eee repres
—{_l2--possible by using cl
| Cato Abstractton =
Data chstrochion means representing _e
| essential features _b Ne all ene
bind ne
method togdher_in o singe entity called class.
lass is “accessible by
2 class. From
_Sf_© component which can he hidden from zest
cf data and
a —enl_melneds ( fndions
Programmers moke use
dole values and metned "tog
tis simply a ccllacten 2f dala (vatiohles)
fons) that oct em Yhese data
class iso Wueprint fer the cbjeck
= thi
Class
mmetheds tha can
tiibutes. Por
Pye the keyrcorc cla:
_2. Class Vosiable t=
Thi
a collection of dato attibules
550
/_maniputabe
defining the cass in
sis Used :
515 a Hind of voviobte
the fanetien
the same class. Tri areal
not accessible’ from the -cutside ef the component.
which is shored by all inst
tones -of class. The
elas,
class vetioile are” defined sittin o class lst |
cutside the class method.
F—1_date
—
> Cf maned
Method
[ Method -
3. Dako member i
Scanned with ACE Scanner5. Class _methed =
Th ig a spectod
Hon uhich 19 defined inside, the class
defini ben -
ee ee
Object t=
Tt is an jestence ofa class. Ao
cbject comprises both dota members _and
evetnod
ofa
% Class Method and Self Object +
| Class Vafobles
|= The vosiobles ot the class tevel are clated
| class variables = —
[The class vodobles are shaved hy all the
instances of the class.
= “They thesefore generally hove same value
|__evéry instance er cbiack. _
[= There is 0 single ccoy 2f class vedable which ig
hored among all the objects , hence the.
change made by on chiec ina sinde espy ef
class’ variable i5 reflected in all ethce chiects.
©
= The class methods ore the funcions defined
inside the clogs. These ove _octuolly Hhe nerenal
fanctions bul belong to thot closs.
= Object Vosiobles i=
ecch sbiect fs called
= The veuobles cwned_b:
= The dass metrod “defines ‘the first _orgument a.
chject_variable
elf. THis is. alongs defined. as the. first
_erquenent -
there is no at t_ko the class method
| = Sp there is ne croument to the clas:
Shen only self will be the -ergymere fer thot
method,
And if ‘there ore some ‘arguments _ present 10
he class mahed then aloays the first
@
will be _selp ond then temeining “will be the
Vist of arguments of that class method =
= The self orquenent refers tothe cbject iteelp.
~The class method ave cessible from outside —
~ Fer each chjeck ev instance of a cla
instance vovables are different:
= Colike class variables , insta
OT defined aithin the methods
|= The _changes_made. sjeck_varieble_w
vosiable.
nek be reflected fer cthex: cbject
= Public and Private Members
~ Publig_vovables are these vasiables that o7e.
defined in the dlass_and can be _occessed from
Nass nd from outside the class.
the closs using objet. Hence these methods [altho the
axe also called as instance metheds. - Ti mumbecs in 9 Pyjhen class ore public by | 4
defoult.
il
Scanned with ACE Scannerx Class Methods %—
~ Piclass method: 1s ar method that is Meuand to
class vother shar its object. Tt does not
require création of class instance.
~The @classmethod clecotator is us - for
class - method: clefinition.
Syntax_3 : oe alnet i
@ classmethed: :
edit sada enn (chs args’. -.) »)
> Note thot the first argument wo the lass methed _
\ is alison ds. _
—|-—The classmethed 0) method veluring a class
| method fori the: given functon: —
€x: class Test (object) +)" boat ajelty
_@ class method :: -
der geeeting: (dls) + ; ‘
pat ("Weleome. ; firddn clés: Yes) »)
ithrols. =oame—).
Wj} Test, sc greslinge.
{| _Olp : Weleome: fo 0! =