2 Objectives Describe the advantages of modularizationModularize a programUnderstand how a module can call another moduleExplain how to declare variablesCreate hierarchy chartsProgramming Logic and Design, Introductory, Fourth Edition

4 Modules, Subroutines, Procedures, Functions, or MethodsUnit of code that performs one small taskCalled a subroutine, procedure, function, or methodModularization: breaking a large program into modulesProgramming Logic and Design, Introductory, Fourth Edition

8 Modularization Allows Multiple Programmers to Work on a ProblemLarge programming projects can be divided into modulesModules can be written by different programmersDevelopment time is significantly reducedProgramming Logic and Design, Introductory, Fourth Edition

9 Modularization Allows You to Reuse Your WorkReusability: the ability to use modules in a variety of applicationsReliability: assurance that a module has been tested and proven to function correctlyProgramming Logic and Design, Introductory, Fourth Edition

10 Modularization Makes It Easier to Identify StructuresCombining several tasks into modules may make it easier for beginning programmers to:Determine if a program is structuredIdentify structures in a programExperienced programmers modularize for abstraction, ease of dividing the work, and reusabilityProgramming Logic and Design, Introductory, Fourth Edition

13 Modularizing a ProgramMost programs contain a main moduleContains the mainline logicAccesses other modules or subroutinesRules for module names used here:Must be one wordShould be meaningfulAre followed by a set of parenthesesProgramming Logic and Design, Introductory, Fourth Edition

15 Modularizing a Program (continued)Calling program (or calling module): one that uses another moduleFlowchart symbol for calling a module: a rectangle with bar across the topFlowchart for the module contains:Module name in the start symbolexit or return in the stop symbolWhen a module is called, logic transfers to the moduleWhen module ends, logic transfers back to the callerProgramming Logic and Design, Introductory, Fourth Edition

18 Modules Calling Other Modules (continued)Knowing when to break a module into its own subroutines or submodules is an artBest practice: place together statements that contribute to one specific taskFunctional cohesion: extent to which the statements contribute to the same taskProgramming Logic and Design, Introductory, Fourth Edition

19 Declaring Variables Declaring a variable involves:Providing a name for the memory location where the value will be storedSpecifying the type of the dataData types used here:num for number valueschar for all other valuesWhere and when a variable must be declared is language-dependentProgramming Logic and Design, Introductory, Fourth Edition

20 Declaring Variables (continued)Local variables: declared within a moduleGlobal variables: declared at the beginning of the program, and used in all modulesAnnotation box: flowchart symbol containing notesData Dictionary: list of variables used in a program, with their type, size, and descriptionProgramming Logic and Design, Introductory, Fourth Edition

22 Creating Hierarchy ChartsIllustrates modules’ relationshipsTells which routines call which other routinesDoes not tell when or why the modules are calledProgramming Logic and Design, Introductory, Fourth Edition

23 Creating Hierarchy Charts (continued)Blackened corner indicates a module that is used more than onceProgramming Logic and Design, Introductory, Fourth Edition

24 Understanding DocumentationAll supporting material that goes with a programTwo major categories: for users and for programmersUsually created by system analysts and/or tech writersMay be printed or electronic (Web or CD)End users: people who use computer programsProgram Documentation:Internal program documentation: comments within codeExternal program documentation: supporting paperwork written before programming beginsProgramming Logic and Design, Introductory, Fourth Edition

25 Output Documentation Usually written firstRepresents the information needed by end usersMay be initially created by end usersPrinted reports: designed using a print chartProgramming Logic and Design, Introductory, Fourth Edition

27 Input DocumentationInput documentation: describes what input is available to produce the outputFile description:Describes the data stored in a fileIndicates fields, data types, and lengthsProgramming Logic and Design, Introductory, Fourth Edition

28 Input Documentation (continued)Byte: unit of computer storage that can contain any of 256 combinations of 0s and 1s to represent charactersProgrammers usually create one variable for each data field in an input fileSome report fields may be calculated resultsProgramming Logic and Design, Introductory, Fourth Edition

29 Input Documentation (continued)Programmers need to know:Data file nameData fields and their order within the fileData types of each fieldProgramming Logic and Design, Introductory, Fourth Edition

33 SummaryModules, subroutines, procedures, functions, methods: smaller, reasonable units of code that provide reusabilityModules can call other modulesVariable declarations define the name and type of the data to be storedHierarchy chart illustrates modules’ relationshipsDocumentation: all supporting material for a programProgramming Logic and Design, Introductory, Fourth Edition

34 Summary (continued) Output documentation: includes report designsFile description: details data types and lengths of each field of data in the fileUser documentation: includes manuals and instructional materials for non-technical people, and operating instructions for operators and data-entry peopleProgramming Logic and Design, Introductory, Fourth Edition

About project

Feedback

To ensure the functioning of the site, we use cookies. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy &amp Terms.
Your consent to our cookies if you continue to use this website.