Structured Programming vs Object Oriented Programming
Object Oriented Programming (OOP) thiab Structured Programming yog ob txoj kev ua haujlwm. Lub programming paradigm yog ib qho tseem ceeb ntawm kev siv computer programming. Programming paradigms txawv nyob rau hauv yuav ua li cas txhua lub caij ntawm cov kev pab cuam yog sawv cev thiab yuav ua li cas cov kauj ruam yog txhais los daws teeb meem. Raws li lub npe qhia, OOP tsom rau sawv cev cov teeb meem siv cov khoom tiag tiag hauv ntiaj teb thiab lawv tus cwj pwm, thaum Structured Programming cuam tshuam nrog kev teeb tsa qhov kev pab cuam hauv cov qauv tsim qauv.
Txoj Haujlwm Kev Ua Haujlwm yog dab tsi?
Nws tau xav tias xyoo yug ntawm Structured Programming yog 1970. Cov txheej txheem kev ua haujlwm yog suav tias yog ib qho tseem ceeb ntawm kev ua haujlwm. Cov txheej txheem txheej txheem yog tsim los ntawm cov txheej txheem ntws yooj yim, uas yog cov txheej txheem hierarchically. Lawv yog cov kab ke, xaiv thiab rov ua dua. Sequence yog ib qho kev txiav txim ntawm nqe lus. Kev xaiv txhais tau tias xaiv ib nqe lus los ntawm cov nqe lus raws li lub xeev tam sim no ntawm qhov kev pab cuam (piv txwv li siv yog cov nqe lus) thiab rov hais dua txhais tau tias ua tiav ib nqe lus kom txog rau thaum qee lub xeev tau mus txog (piv txwv li siv rau lossis thaum nqe lus). ALGOL, Pascal, Ada thiab PL/I yog qee yam ntawm cov txheej txheem txheej txheem siv niaj hnub no.
Object Oriented Programming yog dab tsi?
Nyob hauv OOP, lub hom phiaj yog xav txog qhov teeb meem los daws cov ntsiab lus ntawm lub ntiaj teb tiag tiag thiab sawv cev rau qhov teeb meem ntawm cov khoom thiab lawv tus cwj pwm. Cov chav kawm piav qhia txog cov qauv paub daws teeb ntawm cov khoom tiag tiag hauv ntiaj teb. Cov chav kawm zoo ib yam li cov ntawv sau los yog cov qauv, uas sib sau cov khoom zoo sib xws lossis cov khoom uas tuaj yeem ua ke ua ke. Cov chav kawm muaj cov khoom hu ua tus cwj pwm. Cov cwj pwm yog siv raws li lub ntiaj teb thiab piv txwv hloov pauv. Cov txheej txheem hauv cov chav kawm sawv cev lossis txhais tus cwj pwm ntawm cov chav kawm no. Cov txheej txheem thiab cov cwj pwm ntawm cov chav kawm yog hu ua cov tswv cuab ntawm chav kawm. Ib qho piv txwv ntawm chav kawm yog hu ua ib qho khoom. Yog li ntawd, ib qho khoom yog cov qauv ntaub ntawv uas zoo ib yam li qee qhov khoom tiag tiag.
Muaj ntau lub ntsiab lus tseem ceeb OOP xws li Cov Ntaub Ntawv abstraction, Encapsulation, Polymorphism, Messaging, Modularity thiab Inheritance. Feem ntau, encapsulation yog ua tiav los ntawm kev ua tus cwj pwm ntiag tug, thaum tsim pej xeem txoj hauv kev uas tuaj yeem siv los nkag rau cov cwj pwm. Qhov cuab yeej cuab tam tso cai rau tus neeg siv txuas ntxiv cov chav kawm (hu ua sub classes) los ntawm lwm cov chav kawm (hu ua super classes). Polymorphism tso cai rau tus programmer hloov cov khoom ntawm chav kawm nyob rau hauv qhov chaw ntawm cov khoom ntawm nws cov chav kawm super. Feem ntau, cov npe pom hauv qhov teeb meem txhais ncaj qha los ua cov chav kawm hauv qhov kev zov me nyuam. Thiab zoo sib xws, verbs ua txoj kev. Qee hom lus OOP nrov tshaj plaws yog Java thiab C.
Qhov txawv ntawm Structured Programming thiab Object Oriented Programming yog dab tsi?
Qhov sib txawv tseem ceeb ntawm Structured Programming thiab OOP yog qhov tseem ceeb ntawm Structured Programming yog los tsim qhov kev zov me nyuam rau hauv cov txheej txheem ntawm cov subprograms thaum, lub hom phiaj ntawm OOP yog txhawm rau rhuav tshem cov haujlwm ua haujlwm rau hauv cov khoom, uas encapsulate cov ntaub ntawv thiab cov txheej txheem. OOP yog suav tias yog qhov hloov pauv ntau dua li kev tsim qauv, vim tias OOP cais ib qho kev pab cuam rau hauv lub network ntawm subsystems es tsis tsim qhov kev pab cuam rau hauv hierarchy. Txawm hais tias kev tsim qauv muab qee qhov meej meej, qhov kev hloov me me rau qhov kev teeb tsa loj heev tuaj yeem ua rau muaj kev cuam tshuam los ntawm kev hloov ntau yam subprograms.