Tải bản đầy đủ (.pdf) (56 trang)

information technology assignment 2 unit programming

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.1 MB, 56 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGY

ASSIGNMENT 2

</div><span class="text_page_counter">Trang 2</span><div class="page_container" data-page="2">

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 1 HND Diploma in Computing

Unit number and title Unit: Programming

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand theconsequences of plagiarism. I understand that making a false declaration is a form of malpractice.

Student’s signature:Nguyen Trung Hoa

Grading grid

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

Internal Verifier’s Comments:

Signature & Date:

</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4">

First of all, I would like to thank my mentor Nguyen Hoang Anh Vu for hisconstant support in my studies and research, for his patience, motivation,enthusiasm and rich knowledge. His guidance has helped me throughout the time ofstudying and writing this thesis. Without your wonderful help, I would not have beenable to achieve this.

In addition to my mentor, I would like to thank my friends who have helpedme improve my knowledge of my subject. Not only that, they are always there tosupport me when I need it. And besides, I would like to thank the school for creating allconditions for me to have adequate facilities to help me complete my work.

Last but not least, I would like to thank my family, who gave birth to me from thebeginning and supported me spiritually. They are always behind to care and help me havemore motivation to complete the work well!

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

Iverifythat thework I'vesubmittedfor thisassignmentis allmy own,and thatallresearchsourceshavebeenproperlycredited.

I declare that this is my work, based on my research, and that I have recognized allmaterials and sources utilized in its production, including books, papers, reports, lecturenotes, and any other type of document, electronic or personal communication.

I further declare that I have not previously submitted this assignment for assessment inany other unit, except where explicit permission has been granted by all unit coordinatorsinvolved, or at any other time in this unit, and that I have not duplicated or stolen ideas from thework of others in any way.

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

iv

TABLE OF CONTENT

event-2 Give explanations of what procedural, object-oriented and event-drivenparadigmsare;their characteristicsandthe relationshipbetweenthem.(P2)...2

2.1.4Therelationshipamong eventdrivenprogramming(EDP)andobject-orientedprogrammingsystem (OOPs)andprocedural-orientedprogramming (POP)...10

2.2Analyze thecommon featuresthata developer hasaccess toin anIDE(M2)...11

CHAPTER3:Implementbasicalgorithmsin codeusinganIDE...15

3.1. WriteaprogramthatimplementsanalgorithmusinganIDE. (P3)(LO3)anddeterminedebuggingprocessand explaintheimportanceofacodingstandard (LO4)...15

3.2UsetheIDEtomanage thedevelopmentprocessoftheprogram.(M3)...22

3.3Explainthedebuggingprocessandexplain thedebuggingfacilitiesavailableintheIDE. (P4)...28

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

vi

LIST OF TABLES AND FIGURES

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

viii

LIST OF ACRONYM

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

Programmingplaysanextremelyimportantrolein life.Coming tothisreport,we willlearnaboutunderstandingprogrammingmodelssuchasproceduralprogramming, object-orientedprogramming,andevent-orientedprogramming.

Aswellasthe structure of aprogram,data,andbasicdata,while also introducingstudents to the use of an integrated development environment (IDE), its functions, andsome standard rules, such as naming in code. At the same time, it assists students inlearninghowto createsimpleapps.Let'sfindout inthisassignment!

CHAPTER 2: Explain the characteristics of procedural, object-oriented andevent-driven programming, conduct an analysis of a suitable Integrated DevelopmentEnvironment(LO2)(IDE)

2 Give explanations of what procedural, object-oriented and event-drivenparadigmsare;their characteristicsandthe relationshipbetweenthem.(P2)

2.2Analyze thecommon featuresthata developer hasaccess toin anIDE(M2).CHAPTER3:Implementbasicalgorithmsin codeusinganIDE

3.1. WriteaprogramthatimplementsanalgorithmusinganIDE. (P3)(LO3)anddeterminedebuggingprocessand explaintheimportanceofacodingstandard (LO4)

3.2UsetheIDEtomanage thedevelopmentprocessoftheprogram.(M3)3.3Explainthedebuggingprocessandexplain thedebuggingfacilitiesavailableintheIDE. (P4)

3.4Outlinethecodingstandardyouhaveusedinyourcode.(P5)

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

CHAPTER 2: Explain the characteristics of procedural,object-orientedandevent-drivenprogramming,conductan analysisof asuitableIntegratedDevelopmentEnvironment(LO2)(IDE)

2 Give explanations of what procedural, object-oriented and drivenparadigmsare;theircharacteristicsandtherelationshipbetweenthem.(P2)

Programmingis ajobwhereprogrammersuse availableprogramminglanguages,codes,andutilities tobuildsoftware,programs,applications,games,websites,etc.Userscan perform commands with computers or interact with each other through electronicdevices.[1]

- Structure-orientedprogramming,alsoknownasprocedure-oriented programming (POP):is a traditional programming technique in which a program is divided into functions(subroutines).

- Eachprogram canalsobe dividedintomanyothersubroutinestosimplifytheirwork.(Smoothingprocess)

Figure2-1:Procedure-Oriented Programming

</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">

-nowwewill startwithaddition,subtractionmultiplydivision,thensolvetheequationandfinallyfindmin, max

-wewillputthenumbers inforthemachinetodothecalculation:Example:

+puttwonumbersinaand btoperformaddition:

</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">

-weuse theradiobuttontoswitchto max3tomaketheline Cappeartocalculatetheequation.

-put3 times theadvantage in a, b,c is 2,5, 1we willhavethefollowingresult:

</div><span class="text_page_counter">Trang 30</span><div class="page_container" data-page="30">

Figure3-5:Quadratic+nowwewillperformthe searchforthelargestnumber-wewillputin5numbersas2,5,3,7,4toseehow theresultis:

</div><span class="text_page_counter">Trang 31</span><div class="page_container" data-page="31">

-it'sgreatthatthefunctionsarerunningandtherearenoerrors,allasexpected,iftheuserenters thewrong data,the system willautomaticallynotifythe user,orswitchbacktotheerrorcode.

- Forexample, wesolvethe quadraticequationbutdo notusethe radiobuttoncommandtodisplaythe linetowriteallthenumberstoperformthecalculation,the systemwillreturnthefollowing:

- ErrorSystem.FormatException:'Inputstringwasnotina correctformat.'Whenwewritethewrong code,theprocessisinterruptedbecausethesystemdoesnotunderstandacertaincode,andreturnstheerrorcode.

-Above we cansee theimportanceof a coding standard.+ Theyareaveryimportantattributeofsoftwaredevelopment.

+A codingstandardensures thatall developerswho write code ina particularlanguagewrite according to specified guidelines. This makes the code easy to understand andprovidesconsistencyinthecode.

+ One of the most essential elements in a software system is the consistency of thecodingstandard.Thisisbecauseitpositivelyaffectsthequalityofthesystem.Whileusing

</div><span class="text_page_counter">Trang 32</span><div class="page_container" data-page="32">

thesoftwaresystem,youneedtoensurethattheprinciplesdonotconflictwitheachother.Thesource codethatuses thestandardmust also be inharmonywith thestandard.Thecompleted source code should appear as if the code had been written by a singledeveloperinasinglesession.

3.2Usethe IDEto manage thedevelopmentprocessof theprogram.(M3)

-BeforeusingtheIDEtomanagethedevelopmentprocessoftheprogram,weneedtoknowifitsupportsthelanguageyouareusing.IwilluseVisualStudiosoftwareandtheC#programminglanguage tomanagetheprogram'sdevelopment process.

-WhenstartingVisualStudio,itwill displayaninterface with 4 mainfunctions,inaddition,theleftpartistheprojectsthatwehaveworkedon,itwillbestoredanddisplayedontheleft.

</div><span class="text_page_counter">Trang 33</span><div class="page_container" data-page="33">

-Weclickthiscommand,itwill createanewprojectandI willcreatea projectwithC#languageandstartwithconsole

</div><span class="text_page_counter">Trang 34</span><div class="page_container" data-page="34">

-afterselectingthelanguageandoperatingsystem,thesystemforprogramming.Atablewiththeinformationwillbedisplayedformetonametheproject,wheretostoreit.-Whentheselection isdone,I will clickCreate to starttheproject,-AnIDEhasbeencreated.

Figure3-11:VisualStudio4

</div><span class="text_page_counter">Trang 35</span><div class="page_container" data-page="35">

-nowwewilluseC# languageandenableWinforminterfacetodothisproject

Figure3-12:VisualStudio5

+Iwillstartwith abasic mathproblem:

+Thefirstis toaddfeaturestothewinforminterfacesothat wecancodetheprogram,withthe projecttocalculate theperimeterandareaofthe rectangle,Iusedthewinforminterfacetobuildthefollowing:

</div><span class="text_page_counter">Trang 36</span><div class="page_container" data-page="36">

+whenI havesuccessfullybuilt theinterfaceframework,IcontinuetouseC# languagetocodeit:

-Now Iwill testtheprogram

+westart byenteringtwo numbersincellAandB respectively5 and3, thesystemwillcalculateforusandoutputtheresultto thescreen.

+Error!!!this isabasicerrorinwinform which is“wrongobjectnaming”

</div><span class="text_page_counter">Trang 37</span><div class="page_container" data-page="37">

Figure3-15:VisualStudio8+Nextwefixittobe abletoruntheprogramcorrectly:

Figure3-16:VisualStudio9+wekeeprunningagain

</div><span class="text_page_counter">Trang 38</span><div class="page_container" data-page="38">

3.3

Explain the debugging process and explain the debugging facilitiesavailableintheIDE.(P4)

- Debugging is the process of detecting and removing of existing and potentialerrors(alsocalledas‘bugs’)inasoftwarecodethatcancauseittobehaveunexpectedlyorcrash.Topreventincorrectoperationofa softwareorsystem,debuggingisusedtofindand resolve bugs or defects. When various subsystems or modules are tightly coupled,debuggingbecomesharderasany changeinonemodulemay causemorebugstoappearinanother.Sometimesittakesmoretimetodebugaprogramthantocodeit.

Here’sthedebugging process:1.Reproduce theproblem.

2.Describethebug.Tryto getasmuchinputfromtheusertogettheexactreason.

</div><span class="text_page_counter">Trang 39</span><div class="page_container" data-page="39">

3.Capturetheprogramsnapshotwhenthebugappears.Trytoget allthevariablevaluesandstatesofthe programatthattime.

4.Analysethesnapshotbasedonthestateandaction.Basedonthattryto findthecauseofthebug.

5.Fixtheexistingbug,butalsocheckthat anynewbugdoesnotoccur.[7]

- Debuggingisa processthattakesalotoftime,especially logicrelatederrorsthataredifficulttofindandfix. SoVisualStudioprovidesa debuggingtool,makingdebuggingsimpler,easierandfaster.

-HereIwillwritesome aprojectandlearnthecommonmistakeswhilecodingExampledebugging 1

- Thisis acommonerrorwhenweaccidentallydeletethesign {}orforgettousethissigninthe code,this is a branchmarkfor statements,in thestring {}containsC# statementsthatwhenthe functionis calledit willexecute.followthelogic ofthecodefromstarttofinish,orwhenencounteringthecommandreturn;

</div><span class="text_page_counter">Trang 40</span><div class="page_container" data-page="40">

-firstIneedaprojectwithcodeandform:

</div><span class="text_page_counter">Trang 43</span><div class="page_container" data-page="43">

-Clickontheerrormessagelineitwilldisplaytheerror codeforus.Andthatwillmakeusawareof errorsandfixthemeasily

</div><span class="text_page_counter">Trang 44</span><div class="page_container" data-page="44">

Figure3-23:TestingExampledebugging 3

- Whenwefinishwritingacommandline, wewilladdasemicolon (;),rightafterthecodewewritetoletthe systemknowthatwehaveendedthecurrentcommandline.

- andthefollowingisthemissingsyntaxerror(;)thesystemimmediatelyreportserrorsandforces us to fix them.

</div><span class="text_page_counter">Trang 45</span><div class="page_container" data-page="45">

Figure3-24:Bug-ErrorCS1002 ;expected,fix asfollows:-weclickon2errors onthemessengerbar

- The error here is line 30 and 31, when the error, the system provides us informationabouttheerror,andweperformtheerror correction.

Somenotesinnaming:

</div><span class="text_page_counter">Trang 46</span><div class="page_container" data-page="46">

-Thenamemustnotcoincidewiththekeywordofthelanguage.-Theclass namemust startwith a capitalletter.

-Namethevariableextensively,explainits effect,whyitexists,andthevalueitreturns.-Name cannot begin with a number. It must begin with an underscore _ or a lettercharacter.

- The name given must clarify the meaning, avoid being misled, misinterpreting theproblem

-Avoidusingabbreviationsin parameternames andIDs,if abbreviated, useCamelCasefornaming.Namingrules:

- Donameinterfaceswith adjectivephrases, oroccasionally withnounsornoun phrases.- Doprefixinterface nameswith theletter I, to indicatethat thetypeis aninterface.-It shouldbeensuredthatthe namesdifferonlyby the"I"prefixonthe interfacenamewhenyouaredefininganinterface-classpairwheretheclass isastandardimplementationoftheinterface.

</div><span class="text_page_counter">Trang 47</span><div class="page_container" data-page="47">

-Donotprefixtheclass name(example:"C'').

- Dogivemethodsnamesthatareverbsor verbphrases.

- Donamepropertiesusinganoun,nounphrase,oradjective.

</div><span class="text_page_counter">Trang 48</span><div class="page_container" data-page="48">

- Donamecollectionpropertieswithapluralphrasedescribingtheitemsinthecollectioninsteadofusingasingularphrasefollowedby"List"or"Collection".

- Considergivingapropertythesamenameasitstype.

- Do nameeventswithaverbor averbphrase.

- Dogiveeventsnameswithaconceptof beforeandafter,usingthepresentandpasttenses.

- Donotuse"Before"or"After"prefixesorpostfixestoindicatepre-andpost-events.Usepresentandpasttensesasjustdescribed.

- Donameeventargumentclasseswiththe"EventArgs"suffix.NameofFields[8]

- DousePascalCaseinfieldnames.

- Do namefieldsusing anoun, nounphrase,oradjective.- Donotuseaprefixforfieldnames.

Example:Iwillwriteasynthesisproblem

</div><span class="text_page_counter">Trang 50</span><div class="page_container" data-page="50">

Figure3-32:ex1Severalmethodsof namingobjects

</div><span class="text_page_counter">Trang 52</span><div class="page_container" data-page="52">

<small>+ Result:</small>

</div><span class="text_page_counter">Trang 53</span><div class="page_container" data-page="53">

Figure:3-36:ex3

</div><span class="text_page_counter">Trang 54</span><div class="page_container" data-page="54">

Through the last report, I have applied the knowledge I havelearnedinclassandlearnedonlinetosuccessfullycompletethelessonprogram.IthinkthatIstillhavesomeshortcomings,Istillhavetolearnmore,butIdid mybestandcompletedtheexamassoonaspossible.Iwilltrynexttime.

</div><span class="text_page_counter">Trang 55</span><div class="page_container" data-page="55">

After completing this report, I understood and grasped how tobuild a basic algorithm, models such as procedural programming,functional procedures, object-orientedand event-oriented programming,IDE capabilities , debugging programs and compilation processes.Thankyou.

</div><span class="text_page_counter">Trang 56</span><div class="page_container" data-page="56">

8.type-members

</div>

×