480 likes | 611 Views
Basic Computer Concepts Program Planning and Development Defining the Problem Designing a solution Writing the Program. Software Development. * Property of STI Page 1 of 48. Basic Computer Concepts Program Planning and Development. Compiling, debugging and testing the programs
E N D
BasicComputerConcepts ProgramPlanningand Development DefiningtheProblem Designingasolution WritingtheProgram SoftwareDevelopment *PropertyofSTI Page1of48
BasicComputerConcepts ProgramPlanningand Development Compiling,debuggingandtestingtheprograms DocumentingtheProgram Ø Ø SoftwareDevelopment *PropertyofSTI Page2of48
BasicComputerConcepts ProgramPlanningand Development DefiningtheProblem Ø recognizingtheneedforinformation definingwhatoutputsarerequiredofthe program v v DesigningaSolution Ø breakingtheproblemintodiscretesteps v knownas“algorithm” Flowcharting-agraphicalrepresentationofthe sequenceofoperationsacomputeristoperform SoftwareDevelopment *PropertyofSTI Page3of48
BasicComputerConcepts DesigningaSolution Terminal Generalinput/outputoperation Process Comparison Connector Predefinedprocess Document ManualInput Ø Ø Ø Ø Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page4of48
BasicComputerConcepts DesigningaSolution PayrollFlowchart SoftwareDevelopment *PropertyofSTI Page5of48
BasicComputerConcepts DesigningaSolution Ø Ø Pseudocode-isaversionoftheinstructions describingeachstepthecomputermustfollow PayrollPseudocode Start Reademployee'shoursworkedand hourlywage Dountilendofitems Multiplyhoursworkedbyhourly wagetogetgrosspay Ifgrosspayisgreaterthan70K Thentaxrateis20% Elsetaxrateis15% Multiplytaxratebygrosspay togivetax Subtracttaxandunionduesfrom grosstogetnetpay Printcheck Readnextemployee'shours workedandhourlywage Endloop(nomoredata) Printreports SoftwareDevelopment *PropertyofSTI Page6of48
BasicComputerConcepts WritingtheProgram writetheprograminaspecificprogramming language typesofprogrammingstatements Ø Ø comments declarations input/outputstatements computations transferofcontrol Comparison v v v v v v theprogrammershouldtrytoincorporatethe followingqualitiesintoanyprogram: Ø easytoreadandunderstand efficient reliable robust maintainable v v v v v SoftwareDevelopment *PropertyofSTI Page7of48
BasicComputerConcepts Compiling,Debugging, andTestingtheProgram acompilerisaspecialprogramforeach programminglanguagethatisloadedintothe computerwhenthelanguageisused compilationerrorsarediscoveredbythe compilerandinclude: Ø Ø spellingerrors syntaxerrors improperlysequencedstatements improperlylabeledstatements conflictinvariablenames illegalnamesorstatements missingpunctuations v v v v v v v SoftwareDevelopment *PropertyofSTI Page8of48
BasicComputerConcepts Compiling,Debugging, andTestingtheProgram logicalerrorshavetobedetectedbythe programmerinaprocesscalleddebugging tobesurethattheprogramwillgivethe correctoutput,theprogramhastobetested byrunningtheprogramandinputtingdata withknownoutputs Ø Ø SoftwareDevelopment *PropertyofSTI Page9of48
BasicComputerConcepts Documentationofthe Program documentationconsistsofwrittendescriptions andexplanationsofprogramsandother materialsassociatedwithanorganization’s dataprocessingsystem properprogramdocumentationservesasa guideforprogrammersandanalystswhomust modifyorupdateexistingprogramsandsystem procedures theprocessofdocumentationisanon-going one Ø Ø Ø acompletedescriptionofthecontentsand formatsofalldatainputs,outputsandfiles tobeused astatementofthehardwarerequirements forrunningtheprogramaswellas estimatedprocessingtimeandstorage requirements astatementofsoftwarerequirementssuch asutilityprogramsandlibraryprograms v v v SoftwareDevelopment *PropertyofSTI Page10of48
BasicComputerConcepts StructuredDesign programsmustbestructured,thatis,each majorstepintheprogrammustbedeveloped asindependentmoduleandrepresentedinthe flowchartasaseparateblock programcodeswillbeeasiertounderstandand moremaintainableifyoubreakthelogicinto steps,andencompasseachstepinitsown subroutineorfunction usingstructureddesignleadstothefollowing benefits: Ø Ø Ø earlydetectiondesignflaws programsthatcanbeeasilymodified clearandcompletedocumentation modulardesigntoimprovetesting v v v v SoftwareDevelopment *PropertyofSTI Page11of48
BasicComputerConcepts StructuredDesign Top-downvs.Bottom-up Top-downstructureddesignisdonebyfirst recognizingthemajorcomponentsofthe solution,expressingthesolutionasasequence ofthesemajorcomponentsandthen expandingthemajorcomponentsthemselves similarly. Bottom-updesignstartsbyidentifyingsmall functionsandsubroutinespresentinthedesign andmovinguptowardsmorecomplex procedures. Ø Ø SoftwareDevelopment *PropertyofSTI Page12of48
BasicComputerConcepts StructuredDesign UsingFlowchart generallyinvolvesatop-downanalysisofthe problem basedontheassumptionthattherearefour (4)basiclogicpatternsnamely: Ø Ø Selection SimpleSequence SoftwareDevelopment *PropertyofSTI Page13of48
BasicComputerConcepts StructuredDesign Loop Branch Ø Ø SoftwareDevelopment *PropertyofSTI Page14of48
BasicComputerConcepts StructuredDesign Do-while Case Ø Ø SoftwareDevelopment *PropertyofSTI Page15of48
BasicComputerConcepts ProgrammingParadigm Paradigm Ø an“example,modelorpattern” anidealizedpatternofusageunderwhich someagentcanoperate v v ProgrammingParadigm Ø awayofthinkingaboutproblemsandtheir solutions,oranapproachonhowtousea computertoimplementthosesolutions v Foraprogrammertosolveaparticular problem,heneedstoknowseveralthings, namely: Ø musthaveaclearpictureofwhatthe problemissupposedtodo musthaveanunderstandingofhowthe programshouldworktoproducethe desiredresult mustunderstandhowtheprogramfitsin itsenvironment v v v MajorProgrammingParadigms Ø Imperative Logical Functional Object-Oriented v v v v SoftwareDevelopment *PropertyofSTI Page16of48
BasicComputerConcepts ImperativeParadigm characterizedbyprogrammingwithstatesand commandsthatmodifythestates Imperativemeansacommandororder,while acommandoraproceduremeansaparticular courseofaction. impliesprocedures(orprograms)ordirections forperforminganaction anabstractionofrealcomputers,whichare basedontheVonNeumannmachine assumesthatacomputercanmaintainthrough environmentvariablesanychangeinthe computationprocess Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page17of48
BasicComputerConcepts ImperativeParadigm Popularprogramminglanguagesaremoreoften imperativemainlybecauseoftworeasons: Ø itcloselyresemblestheactualcomputer ormachineitself,sotheprogrammeris muchclosertothemachine itistheonlyoneefficientenoughfor widespreaduse v v Advantage: Ø canbeeasilytranslatedtoanefficient machinecode,sotheyareconsidered highlyefficient v Disadvantage: Ø someproblemsarehardtomodelusing thisparadigm v SoftwareDevelopment *PropertyofSTI Page18of48
BasicComputerConcepts ImperativeParadigm Ø Ø Whenitiscombinedwithsubprogramsitis calledproceduralprogrammingalsocalled structuredprogramming Anexampleofanimperativeprogramthatwill computethefactorialofagivennumberis: Functionfactorial(n) { varx=1; while(n>0){ x=x*n; } n=n-1; returnx; } SoftwareDevelopment *PropertyofSTI Page19of48
BasicComputerConcepts LogicalParadigm takesadeclarativeapproachtoproblem- solving canbedividedintothree(3)steps: Ø Ø aseriesofdefinitions/declarationsthat definetheproblemdomain statementsofrelevantfacts statementsofgoalsintheformofqueries 1. 2. 3. Advantages: Ø thesystemsolvestheproblem;so programmingstepsarekepttoaminimum sinceitislargelybasedonmathematical logic,provingthevalidityofagiven programbecomessimple v v SoftwareDevelopment *PropertyofSTI Page20of48
BasicComputerConcepts LogicalParadigm Anexampletoillustratethelogicalparadigm: Ø SoftwareDevelopment *PropertyofSTI Page21of48
BasicComputerConcepts FunctionalParadigm basedonfunctionalexpressionsandthe evaluationoftheseexpression viewsallprogramsasfunctionsina mathematicalsense toillustrate,thefunctionalprogramexpressed infunctionalparadigm: Factorialn= Ifn=1then1 Else n*Factorial(n-1); Advantages: Ø Ø Ø Ø provideahighlevelofabstraction;the programmingbecomesmodularand removesthepossibilityofcreatingmany errors notheavilydependentontheassignment operation,sotheprogramscanbe evaluatedwithmanydifferentorders muchmoreamenabletomathematical proofandanalysisthanimperativeones v v v SoftwareDevelopment *PropertyofSTI Page22of48
BasicComputerConcepts FunctionalParadigm Disadvantages: Ø hardtoimplementefficiently,becauseitis hardtodetermineifdatastoragecanbe re-usable forproblemsinvolvingmanyvariablesora v v lotofsequentialactivity,itissometimes easiertohandlethemimperativelyorwith object-orientedprogrammingparadigms Functionforcomputingtheaverage oftwonumbers: (defunavg(XY)(/(+XY)2.0)) Functioniscalledby: >(avg10.020.0) Functionreturns: 15.0 SoftwareDevelopment *PropertyofSTI Page23of48
BasicComputerConcepts Object-Oriented Paradigm Ø Ø aparadigminwhichrealworldobjectsare viewedasseparateentitieshavingtheirown stateandexhibittheirownbehavior focusesontheobjectsthattheprogrammeris representing Illustratesobjectsandhowtheyare encapsulatedintomodules Objectinterface DATA Methods SoftwareDevelopment *PropertyofSTI Page24of48
BasicComputerConcepts Object-Oriented Paradigm Object-oriented programmingapproach in Ø generalcanbedividedintofour(4)steps: Identifytheproblem Identifytheobjectsneededforthe solution Identifymessagestobesenttotheobjects Createasequenceofmessagestothe objectsthatsolvetheproblem v v v v Ø Toillustratethefour(4)steps: 1.Problem Identification:Computethesum oftwonumbersandprintouttheresult 2.Object Identification:Identifyobjects neededtosolvetheproblem •Num1-firstnumber(object) •Num2-secondnumber(object) •Sum-resultoftheadditionofthetwo numbers SoftwareDevelopment *PropertyofSTI Page25of48
BasicComputerConcepts Object-Oriented Paradigm Toillustratethefour(4)steps(cont.): 3.Message Identification:Messagesneededto sendtoobjects +aNum-thisisthemessagesenttothe receiverobjectwithparameteraNum.The resultofthismessageisthevalue(a numericobjects)ofthetotalsumofthe receiverobjectandaNum print-amessagethatdisplaysthevalueof v v thereceiverobject 4.Objects-Message Sequences: (Num1+Num2)print Themessage+withparameterNum2is senttoobjectsNum1.Theresultisan object(Num1+Num2),whichissentthe messageprint. v SoftwareDevelopment *PropertyofSTI Page26of48
BasicComputerConcepts OtherProgramming Paradigms Tree-thisisviewingcodeordatainahighly hierarchicalmanner ExpertSystem-thisorganizesdatabyusinga listorpoolofrulesthataresometimes constantlyrecycledthrough Stream-isbasedontheideathatinputand outputofsmallerprogramsorutilitiescanbe linkedtogether NeuralNetwork-basedontheconceptsthat computersareprogrammedinthesamewayas howhumansthink 1. 2. 3. 4. SoftwareDevelopment *PropertyofSTI Page27of48
BasicComputerConcepts ProgrammingLanguage Languageisdefinedasasystemfor communicating. Writtenlanguageusesymbols(characters)to buildwords. Theentiresetofwordsisthelanguage vocabulary. Thelanguagesyntaxandgrammardefinethe wayinwhichthewordsaremeaningfully combined. Theactualmeaningofwordsandcombinations ofwordsisdefinedbythelanguagesemantics. Ø Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page28of48
BasicComputerConcepts MachineLanguage thelowestlevelofprogramminglanguage onlylanguageunderstoodbycomputersand consistsofpurenumbers;takestheformof “1”or“0” eachmachineinstructionhastwo(2)parts: Ø Ø Ø opcode(operationcode)-whichtellsthe computerwhatfunctiontoperform operand-whichtellsthecomputerwhat datatousewhenperformingthefunction v v SoftwareDevelopment *PropertyofSTI Page29of48
BasicComputerConcepts Low-levelLanguage Ø alsocalledassemblylanguageandissimilarto machinelanguagebutassemblylanguageis mucheasiertounderstandthanmachine language Examplesofmnemoniccodes SoftwareDevelopment *PropertyofSTI Page30of48
BasicComputerConcepts Low-levelLanguage Programmerswhowritelow-levellanguage programsmustbehighlyskilledintwo(2) areas: Ø mustknowagreatdealabouttheinternal workingsofthemicroprocessor,anda broadtechnicalknowledgeofthe computerisneeded mustbeverydetailoriented;everystepof v v thecomputermustbecoded,andthe actualnumericaladdressofthe instructionsanddatamustbespecified Anexampleofusingtheassemblylanguageto multiply87and243andsavingtheresult inthememory SoftwareDevelopment *PropertyofSTI Page31of48
BasicComputerConcepts High-levelProgramming Language enablesaprogrammertowriteprogramsthat aremorelessindependentofaparticulartype ofcomputer consideredhigh-levelbecauseit’scloserto humanlanguagethanthemachinelanguage thatthecomputerunderstands easiertounderstandandallowsthe programmertofocusonsolvingtheproblem ratherthanknowinghowtoprogramthe computer examples:Ada,Algol,BASIC,COBOL,C,C++, FORTRAN,LISP,Pascal,Prolog Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page32of48
BasicComputerConcepts BASIC Beginner’sAll-purposeInstructionCode developedbyJohnKemenyandThomasKurtz intheearly1960’s intendedasaneasy-to-learninteractive languageforthestudents Advantages: Ø Ø Ø Ø simplicityandflexibility allowsbasicmanipulationoftext providesbuilt-infunctionssuchas v v v logarithms,squareroot,trigonometric functions,andrandomnumbergenerator AnexampleofaBASICprogramthatwillmultiply twonumbers,243and87andprintingtheresult SoftwareDevelopment *PropertyofSTI Page33of48
BasicComputerConcepts FORTRAN FormulaTranslator theoldesthigh-levelprogramminglanguage developedinthemid-1950’sbyJohnBackus primarilyintendedasahigh-levellanguage usedforprogrammingscientific,mathematical andengineeringapplications Advantages: Ø Ø Ø Ø Ø procedure-orientedlanguagewith excellentmathematicalcapabilities itspatternissimilartotheBASIClanguage, aprogrammerwhoisfamiliarwith FORTRANcaneasilywriteprogramsin BASIC v v Disadvantages: Ø closelyresemblesmathematicalnotations; thus,itisverydifficultfornon- programmertounderstandorfindthe errorsintheprogram notsuitedasabusinessapplication languageforitdoesnothavethecapability todevelopprogramsthatinvolvefile maintenance,editingofdata,ordocument production v v SoftwareDevelopment *PropertyofSTI Page34of48
BasicComputerConcepts FORTRAN AnexampleofaFORTRANprogramthatwill multiplytwonumbers,243and87andprinting theresult SoftwareDevelopment *PropertyofSTI Page35of48
BasicComputerConcepts COBOL CommonBusiness-OrientedLanguage themostfrequentlyusedbusiness programminglanguage usedextensivelyinbusiness,education,and government startedintheearly1960’swhenacommittee ledbyU.S.DepartmentofDefenseandother computerusersandmanufacturersknownas CODASYL(ConferenceofDataSystems Languages)wantedtodevelopacommon businessprogramminglanguage Dr.GrayMurrayHopperwasamajor contributortothestructureanddevelopment oftheCOBOLlanguage Ø Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page36of48
BasicComputerConcepts COBOL Advantages: Ø easytounderstandbynon-programmers sinceitisEnglish-like self-explanatoryandwell-documenting goodliterarycapabilitywhichmeansthat itisgoodinmanipulatingwords, sentences,orparagraphsoftextmaterial strongfile-handlingcapabilities machine-independent v v v v v Disadvantages: Ø programstendtobewordyandquitelong limitedcomputationalcapabilitieswhich makesitinappropriateforapplications thatrequirecomputations v v SoftwareDevelopment *PropertyofSTI Page37of48
BasicComputerConcepts COBOL AnexampleofaCOBOLprogramthatwill multiplytwonumbers,243and87andprinting theresult SoftwareDevelopment *PropertyofSTI Page38of48
BasicComputerConcepts PASCAL thelanguagenamedaftertheseventeenth centuryFrenchmathematicianBlaisePascal whoconstructedoneofthefirstadding machines ahigh-levellanguagedevelopedbyNiklaus WirthofZurich,Switzerlandinthelate1960’s oneofthefirstlanguagesdevelopedusinga structuredprogrammingapproach Pascalprogramsconsistofmodules,andeach moduleperformsaspecificfunction. Thestatementsinthemodulecanbe organizedintolevels,andthelevelofthe statementisshownbyitsdegreeofindention fromthemargintofollowtheprogramlogic easily. StatementsinaPascalprogramarecomposed ofreservedwords,symbols,andidentifiers. Reservedwordsarewordsthathaveaspecial meaningtothePascalcompiler. SymbolsusedinPascalincludemathematical symbolsandpunctuationmarks. Identifiersarenamesthatrepresentvarious constants,variables,procedures,orfunctions. Ø Ø Ø Ø Ø Ø Ø Ø Ø SoftwareDevelopment *PropertyofSTI Page39of48
BasicComputerConcepts PASCAL Advantages: Ø relativelyeasytolearn powerfulandefficientlanguage stronggraphicscapabilities v v v Disadvantages: Ø notasstandardasCOBOLorBASIC poorinputandoutputcapabilities limitedfile-handlingcapabilities doesnotpossesstheabilitytomanipulate v v v v largecollectionofnumbersorwords AnexampleofaPascalprogramthatwillmultiply twonumbers,243and87andprintingtheresult SoftwareDevelopment *PropertyofSTI Page40of48
BasicComputerConcepts PASCAL Theprogramcomputesfortheaverageof numbersreadfromaninput SoftwareDevelopment *PropertyofSTI Page41of48
BasicComputerConcepts CLanguage ahigh-levelprogramminglanguagedeveloped byDennisRitchieattheBellLaboratoriesin 1972 namedC,becauseitwasinfluencedbyanother languagecalledBdevelopedbyKenThompson originallydesignedasasystemsprogramming language,whichmeansthatitwasusedto writeoperatingsystemsprograms Advantages: Ø Ø Ø Ø allowsdirectmanipulationofbits,bytes andwordsthatissimilartoassembly language usefulfornumerical,textprocessing,and databaseprograms verygoodgraphicsprogramming capabilities v v v SoftwareDevelopment *PropertyofSTI Page42of48
BasicComputerConcepts CLanguage Disadvantage: Ø notintendedasalanguagefornon- v programmers,unlikeBASICandCOBOL;if youarenotfamiliarwiththelanguage,you cannotunderstandthestructure AnexampleofaCprogramthatwillmultiply twonumbers,243and87andprintingthe result SoftwareDevelopment *PropertyofSTI Page43of48
BasicComputerConcepts C++Language developedbyBjarneStroustrupwhileworking attheBellLaboratories consideredasasupersetofC,andithasthe Ø Ø samecapabilitiesasCwithaddedobject- orientedfeatures AnexampleofaC++programthatwillmultiply twonumbers,243and87andprintingtheresult SoftwareDevelopment *PropertyofSTI Page44of48
BasicComputerConcepts JAVA popularprogramminglanguageforcreating applicationsontheweb “Oak”,wasdevelopedinDecember1990by SunMicrosystems TheJavalanguagewastheperfectlanguage fortheInternetbecauseofthefollowing: Ø Ø Ø Simpleandfamiliar Object-oriented Architecture-neutral Portable Distributed Secure v v v v v v SoftwareDevelopment *PropertyofSTI Page45of48
BasicComputerConcepts Interpretersand Compilers CompilersandInterpreterstranslateahigh- levellanguagetomachinelanguage SoftwareDevelopment *PropertyofSTI Page46of48
BasicComputerConcepts Compiler aprogramthattranslatesaprogramwrittenin ahigh-levellanguage(sourcecode)and translatesitintomachinelanguage(object code) theadvantagesanddisadvantagesofa compiledcodeoveraninterpretedcodeare thefollowing: Ø Ø Compiledmachinecodesrunmuchfaster thaninterpretedones Compiledcodesoccupylessmemoryduring execution Onceaprogramiscompileditcanbere- runanytime Theprogramcanonlybeexecutedonce thetranslationiscomplete Anychangetothesourcecoderequiresa completerecompilation v v v v v SoftwareDevelopment *PropertyofSTI Page47of48
BasicComputerConcepts Interpreter translatesandexecutestheprogramlineby line translateshigh-levelinstructionsintoan intermediateform,whichitthenexecutes theadvantagesanddisadvantagesofan interpreterarethefollowing: Ø Ø Ø Theinterpreterprogramisloadedinto memoryalongwiththeprogramsource codesoitusesmorememorythen compiledcodes Nocopyofthetranslatedcodeexist;ifyou wanttore-runtheprogramitmustbe interpretedalloveragain Interpretedcodesaremuchslowerthan compiledcodes Itisfasterandeasiertodetecterrorsin theinterpretedprogramthanthecompiled program Itiseasierandfastertomakechangesto theprogramwhichmakesdevelopment timefasterespeciallyforlargeprograms v v v v v SoftwareDevelopment *PropertyofSTI Page48of48