information technology assignment 2 unit programming

56 0 0
Tài liệu đã được kiểm tra trùng lặp
information technology assignment 2 unit programming

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

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.. Without

Trang 1

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGYASSIGNMENT 2

Trang 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

Trang 3

Internal Verifier’s Comments:

Signature & Date:

Trang 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!

Trang 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.

Trang 6

ivTABLE 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

Trang 8

viLIST OF TABLES AND FIGURES

Trang 10

viiiLIST OF ACRONYM

Trang 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)

Trang 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

Trang 28

-nowwewill startwithaddition,subtractionmultiplydivision,thensolvetheequationandfinallyfindmin, max

-wewillputthenumbers inforthemachinetodothecalculation:Example:

+puttwonumbersinaand btoperformaddition:

Trang 29

-weuse theradiobuttontoswitchto max3tomaketheline Cappeartocalculatetheequation.

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

Trang 30

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

Trang 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

Trang 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.

Trang 33

-Weclickthiscommand,itwill createanewprojectandI willcreatea projectwithC#languageandstartwithconsole

Trang 34

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

Figure3-11:VisualStudio4

Trang 35

-nowwewilluseC# languageandenableWinforminterfacetodothisproject

Figure3-12:VisualStudio5+Iwillstartwith abasic mathproblem:

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

Trang 36

+whenI havesuccessfullybuilt theinterfaceframework,IcontinuetouseC# languagetocodeit:

-Now Iwill testtheprogram

+westart byenteringtwo numbersincellAandB respectively5 and3, thesystemwillcalculateforusandoutputtheresultto thescreen.

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

Trang 37

Figure3-15:VisualStudio8+Nextwefixittobe abletoruntheprogramcorrectly:

Figure3-16:VisualStudio9+wekeeprunningagain

Trang 38

3.3Explain 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.

Trang 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;

Trang 40

-firstIneedaprojectwithcodeandform:

Trang 43

-Clickontheerrormessagelineitwilldisplaytheerror codeforus.Andthatwillmakeusawareof errorsandfixthemeasily

Trang 44

Figure3-23:TestingExampledebugging 3

- Whenwefinishwritingacommandline, wewilladdasemicolon (;),rightafterthecodewewritetoletthe systemknowthatwehaveendedthecurrentcommandline.

- andthefollowingisthemissingsyntaxerror(;)thesystemimmediatelyreportserrorsandforces us to fix them.

Trang 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:

Trang 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.

Trang 47

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

- Dogivemethodsnamesthatareverbsor verbphrases.

- Donamepropertiesusinganoun,nounphrase,oradjective.

Trang 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

Trang 50

Figure3-32:ex1Severalmethodsof namingobjects

Trang 52

+ Result:

Trang 53

Figure:3-36:ex3

Trang 54

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

Trang 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.

Trang 56

8.type-members

Ngày đăng: 10/05/2024, 22:12

Tài liệu cùng người dùng

Tài liệu liên quan