Oops

You might also like

Download as pdf
Download as pdf
You are on page 1of 14
f y in é ° Caren Carer Object Oriented Programming With A Real-World Scenario otc eaten - eerenieaace tas arene Inieens your proranmet rar areal won epaing 00 and may al rhe. “sie he razon arn wg ths arcle Tate fe many intanded forte aucianca who knows the Cec Onented Programming (00?) concept theoretsly bare able olinkie wth rel word & propamming wo FEATURED ARTICLES We wre programsto sok ou problems ad ge our work done a Object Oeted Programing i considered asa desin methodology forbuldng non safae Ih ae cure santo (0075 ever loc writen to et or work done but represented inform of Objects OOP alow: uso break tur problems small nt of work thats reprereted viacjetandtheirfretons Webslfuncions Theory Ot Aue ita! Nework Wt Four Han Sound obec Oniate ‘Tete ce mal fou prs fans of OP. allo hese forester presented programing the SSR Ot por Desgn Ung Mos Report programming cae peres Objet Oriented Programming bale 1. Abetacion vena 2 encapalavon 5 Inbertanee xpd 4 Poymer Pera stiteicey Let's consider an example explaining each ofthese pillars so you can beter understand Object Oriented Programming Before that we needa nom something, \When we thinkofa mobilephone ean object. sec unconaity for uhich as invented were Calg & Receting cal Messoging. Bur now a days thousands of new features and models were added andthe features and numberof model are tl growing ‘TRENDING UP y ot ign ey angen (02 Encapsulation injava Ej es . Cas E+ Cas e+ Corer ear e4 Caren Org A op Tete Couns nga 0 Inabovedagan each brand samsung oka, Phone have ther own toffee angwinbase 05 Das And ren " functonaty of ing reewnga cal and messaging reo nome How To negate Application Insights no awe 6 Fentons Objects 7 TM TO Send And Read Messe From Re ‘Ayre wet which can have some characteris or hh can perfor same sk sealed as Objen,_°7 Serve Bu Ques Ung rue Functions ‘Tsabject sai ale an stance Le. copy fey proganirg inguae we conser te sb Reale ng 1 Appian Wh Sgn armies mabiemanctamurng company en be cba Esenobjaereanbs erent seed onsher™ 08 oy po Charsterses, For example, here are tw objects. (09 Angule 11 New Features fu | nobste anna sey otite 10 Gating Sates win NET SO vewal @ Class ‘Adlassin OOP i 2 plan which describes the object. We call ablueprir of how the obfet should be represented. Mainly a cass would consis ofa nam, arbts. nd operations. Cansiceing the above trap the Noble can be alas hich has sme at butes ke rofl Type, MEI Number, Processor, and Some ore tan have operations ike Dial Receve and SendMessage ‘There ae some OOPS principle that ne oe sted whe cresting clas. This principle called a SOLD ther each ter has Some spedfation. wot be gang into this atts deeper. single ofeach explanation may dear you wth some points, 1. SRP The single Respontbty Principe - das should have ane and only ne espentbiy 2.0CP Tha Open Closed Principe) You should beable to extend classes Behavor, wthoutmadting (inheritance) LSP The Liskov Substitution Principe - Derived clases must be substitablfor tel base asses. (Polymorphism) 4.150 (he nerfaca Spregation Princile)-Make fine choppedintcace instead of huge interface as chant cannot be ered te mplerent an interface which they dont Use '5.DIP [The Dependency Inersln Princ} - Depend on abstractions, nat on concretions (Abswacion) you want to learn mare about SOLD principles, checkout SOL Archtetral aterm el World saree Now let's take lok at our das. pica las based oa the above discussion lokslite the flowing a al Studie Basse Ince programing language 2 ass has members, These members are called properties, methods, elds, Inco the Mole class ook he the allowing: age In ce programming anguage. a dass has members. These members ave cle properties, methods, elds, constructs, dest ucts event ands0 on Incode the Mobile class looks ke the folowing: t prtvete string TentCede { gets sets) lic int tnternitnory Ceety ubite toot TeSingleson { Bet; tet; ) pubis vote Gut enced) t Concate neSteLine(“I0\l Case — 160938343035235")5 ? pte vata O1a1() r concale neste ine" 3 mabe) s d ubise vot Racesve() t ConsotestrsteLine(“teceive » sli"); > Iubise virtunl vosd Sendessoge() ConsolestrSteLine"essone Sent); > Ahetrartinn Abstraction allows us to expose ted data an functional of ebcs pully and Hide the acl Implemertaton. isthe mest important plan OOPS nur example of Mel cas and objets ke Nokia, Samsung IPhone, Some festres of mobiles, 1.Dialing a number cal some method internal which concatenate te numbers and dspays ton seen bbutuhatsttdang we dort know 2. Cicking on green button acl Send signal to aling person's mobile but Weare unaware of haw tis oir Tiss called abstraction. In clases, we an create maods hat canbe called and used bythe users ofthe Case 3 N £ FEATURED ARTICLES How To creat SQt Server Database Project th v Visual Sto ‘We wee programs to sli ou problems and get our work done in Angola 11 New Festures ‘objec oriented Progranming ic considered a a dsign metodalagy for bug non-ghd sft a ss sunesancvons S 00% every wien to ge our work done, bt represeted nform of Oects. OOP allows usiobreak What . © ow probes ino small unico work thats represented vacjects andthe functions. Webuil functions Theory Of Azure Vital Network With Fur Hands round object, oniats There are mainly four plas (eaures) of OOP. allo hese our features represented in programming the Si (ADL} Report Design Using Microsoft Report onmed to another mobile or bluetoath enabled devices but Tm not able to acces the cher mabe features Ike dling arurber, accessing inbox et This is because Bluetooth features given somelevel of abstracion. ‘Avotes pois when mobile Als connected with bile 8a Suetoth whereas mobile Bis aesdy ‘connected to mobie then A's not allowed to connect Ma Tiss because of accesibaty restriction, Ince, aciasshas access modes such a publ. vate, protected and intemal These access modes allows propertils and methods tobe exposed or retried tothe outside World. DL] private string IEICode = "76587556757856"; Polymorphism Carer Polymorphism canbe dined asthe aby of using the sare name for doing ferent things. More precisely ‘we ayit as many forms of single ety. This ply tal rola nthe concep of COPS. ‘Avcee pots when mabile Ais connected with rable Ba Bluetooth whereas mabile Bic aleady onnectado mabie then Ano alowed to connects B. Ths beause of scerby restriction Ince, aclasshas access modes suchas public. private protected and interna: These access modifiers Allows properties and methods tobe exposed o restied tothe outside Word. OL] private string IECode = 75567555757656"; Polymorphism Polymorphism canbe dined asthe aby of using the sae name for doing ferent things. More precisely we Saya: many fms single ey. Ths pay aval olen the concept of OPS, Oarer Lets say Samsung mabe ae a SMP camera avalabla ie Itching functonaity of Camera. Now "ame mobi shaving Panorama mode avalblen camera, 0 funcoalty woud be same but wth mode, $e type te said tobe Stace polmarpham or Compl time polymorphism, Sethe example bel pote ee sams = publde vote GeeaFiComeetion() t ‘onsole.riteLine("WFL comected"); » U7thse $e one method sch shows camars functionality bubtse vote Coneroliee() t » U/0his is one overtone method sich shows camera fonctSoneity os well but with NE SAU ERETEE IES eta » consolesritetine("Caners clicked"); onsale unite sne("Carers clickas Sn” + Canaralde + * Noes") ) Ceara Carer Oas G+ Case Cas Gr ‘Compile time polymorphism the compler knows which overloaded method tisgongto call. Compiler checks the type and number ofparamters passed tothe method and decides which method tall nd vl gh an ero there ce na methods tat mathe: the mathod senatre ofthe method tate Caled at complete. Another poi wherein SendMessage war intended to send mescagetosnge persona atime but suppose "kia had guen provision for ending message to a group at anc. a. Gnetidng ta functionality ta nd message toa group Ths types calle Dynamic polymorphs of Runtime po}ymorphism For overriding you needo set the methed, whic can be overridden to tual & ts new mplementation Soul be decrate with override keyivor. | 83. |‘ punase vote cetsiuetesthcannection() lf . ConcatestesteLine(“Diustasthesnnset se) > Ge: | yeu inptenentation for this asthad uiich wee available in Mobile Clase 85. | this Te runtinepolymorghion Be) Gases eke eure) 2 Concate neSteLine("Horsage Sot 9 2 group"); wl] > aly ‘Byrontme polmmorphiem we cn pont ary dered class fromthe objectofthe base ass at runtime that shows the ably of untime Binding. Inheritance Banbertance Inpertance isthe aby t extend the unctonalty fom base ent in new ety belonging to same group “This wil help usto reuse the tuntonaly which sendy defied Before apd extendas new any, Considering the example, the above ure 1.1 ts shows whats inettance Base Mabie funciona sto senda message, dal and recsve a cal o the brands of mobi fusing thisbare functonalty by exercing the mebile ds funcionaty and adding ther un na features tothe respacive rand. “There are many a1ypes inheritance, 1. singe evel nnentance 2.Multevelinerance $3 earciealinbertance “4 Hyoné nhertance 5: Multlaonertance Single evelinbercance In Single av ionertance, here single bake das & single daved clase, -Abase mobil fetures ie enended by Samsung bran. sng evel neta Mutitevel inheritance InMuttevel nnerance theres rare than one single level of derwation. Le. - Aer bas features ae extended by Samsung brand. Now Samsung brand has manufactured is new model wh new aed features Sr aaa eres Mutitove inheritance InMotfevel nnertance theres roe than one singe evel of deration.e,-Ater base features re rtended by Samsung brand. Now Samsung byand has manufactured ts new model ith nw ade features ‘or advanced OS Ike Android OS, 442 that) From genealeation, geting into more speccaten. Hiororchal inheritance Intis pe of inhertance, multiple derived class would be extended rom base lass,’ smiarto sng evel Instance but ths ume along th Samsung, Nokia's also taking pat in nhertance, ft y in 6 ° Cas G+ fSeen CaF E+ CaF G+ icrarchal inheritance Inthe etinneranc, mult rv lee ula be extended ram bate cles, es miare sng vel inheritance but his be along with Samsung, Nokia's also taking pat in nhertance, Hybrid inheritance Single, Multlve & hlrarcalinhetance altogether constuc a hybrid nhertance, ye inertance poss een 1 eropersise , nea | ¢ Properties linea Heroperties ‘inethoss > ¢ 1 /oropertice iihetieds ) Interface "Muto ohertance where deriv class wil ertend frm mult base clases ‘Samsung il use he functon of mutpl Phone (Mobil & Telephone). This woul create 2 confusion for compli to understand which function to be ced when any eventin mobiles rgere ike Dal whee Dial Isavalable nozh the Phone e-(Meble & Telephone) To elds contusion Ce camewth the conceprf interface which s ferent rom multiple inhertance actual we take an interface itis sim to alos but wthout implementation & ony dedaration of properties methods, delegates & events interface actual enforces the css to have a standard contract prowde all Implementation tothe terface members. Then whats ethe use oferfae when they donot have any Implemertauon? Answers they are hapfl for having readymade contacts, only we need to implement funconalty ever this contract. | mean to say, la! would remain Dan cas of Mobil or Telephone. twon' be ar ifwe give ferent name ‘hen hs take cathe person. Incartce ie dfined with he keyword inerac’ Al poparces& mathods ith inthe interface should be Implemented ts been used. Thats the rule of ierace, Pncertace « oid 05610): Snterfce Mote © void 0i010, f , | setertace reterhone @ENGINEERING QOlibreterts- 'Q. How can we help you? share by vote ntets| fe Hove > GR Cons lces > Data Colepe > HI CSlL-Inomaire Sere >») 2: lomo Sar Sle ne 1.1; Language Generations Bg inten 7 29 40 posonamnanes| 2 cnte mans» Ea eso tae pst rls eens sions an uses aes) ab Uy ‘Scam sy Fon Generations of Programming Languages arly languages were speci othe type of hardware that had tobe proorammed; each type of computer hardware ha a diferent lon-evel programming language (infact, even today there are ferences a the lover lve, though they are now obscured by Figher-eve programming languages) In these eat languages, very speci instructions had to be entered line by linea tedous process Frat generation languages are clad machine code, In machine code, programing is dane by dct salting actual ons and zeros (the bts) n the program ‘sing binary code. Here isan example program that adds 1234 and 4321 using machine language: Assembly anguage isthe sacond-generaton language. Assambly language gles engishike phrases to the machne-code nstrutons, making teaser to program, ‘An esserbij-language progrem must be run though an assembler, which converts tito machine code, Here san example program that adds 1234 and 4321 sing assembly language: Wov €,3234 ov 08: (23 0% Wav 04,4321 ov 05: fo} oy 8,05: (27 nov 052(4] Ax ‘Thie-generation languages are not speci to the type of hardware on which they rn and are much more tke spoken languages. Mos thed- generation languages, ‘aust be comple, a press that converts them into machine code. Wallknown thir generatin languags include BASIC, C, Pascal, and Java. Heres an example ‘sing BASIC: Fourt-generation languages ae a dss of programming tools tht enable fst appiation development using intultve interfaces and ervronment. Many times @ fourth-generation language has very spec purpose, such a5 database Interaction or repor-wrtng, These tocs can be used by those with very ite formal ‘ening in pregramming ad allow for the quick development of appliations andr funcional. Examples of fourth-goneration languages inde: Clipper, FOCUS, FoxPro, SQL, end SPSS. Wy would anyone want to program in a ower-evel language when they requre so much more work? The ansver similar to hy some prefer to dive stkshft autorobles instead of autoratic tansmission: cortrl and eficency, Lower level languages, such as assembly language, are much more efficent ad exec.te much more quick. You have finer conto ver the hardware as wel. Sometimes, a combination of higher and lowerevel languages are med together to get the best of both words the programmer wl create the oveal structure and interface using higher-level language but wil use lower-level languages forthe parts of the program that are used many tines or require more precision. ‘The programming language spectrum (cick to erage) Compiled vs. Interpreted ‘sides clsstyng a program language based on its generation, # can alo be casi by whether it compiled or interpreted. Ac we have lsamed, 2 computer languages oriten ina human-readable frm. In compile language, the program code wansated into & machine-readable form called an exeoutabe that can be anon the harcore, Some wallenown compl nguages include C, C++, and COBOL, ‘An interpreted language is one that requrs a runtime program tobe installed inorder to execute. This runtime program then intxpets the pragram codeine by ne and runs Interpreted languages are generaly easier to werk wth but ao are slower and require more system resoures, Exar of popular interpceted languages include BASIC, PH, PERL and Python. The web languages of HTML and Javascript would also be considered interpreted because they require & browser fn order to un ‘The Jova programming language isan interesting exception to ths clssifiation,asitis actualy a hybrid ofthe two. A program witan in Java partially compe to cet a program that can be understod by the Java Vital Machine (BVM), Each typeof operating system has Rs own JUM which must be installed ich Is what allows Java programs to run on many dfrentiypes of operating systoms. Becktotop 4 4240: Progen Lange | 1.2 Comp Iterated » ‘he Leet rar are Pe by Minox and are supper bythe Department of Education Open Textbook Pi Proje, the UC Das Ofc the Pow, te UC ‘ave Libary, the Calo Sate Unies Afirdabl Leaning soluons Progra, ard Mat We alo adkowedpe revous Natal dence Fountain support une rat ‘umber 1246120, 152505), and 141273, Unies others note, Uren content ened by Cr #-NSh Logs. Mave quatre comets? Fr mre non ‘ortt us tif breton rg or chek xt or sis ge at ost lets. Peace @ UCDAVIS ¥MERLOT pcos SoutTioNs iats) USVERITYOF CALC

You might also like