chapter 10 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 10 PowerPoint Presentation
Download Presentation
Chapter 10

Loading in 2 Seconds...

play fullscreen
1 / 30

Chapter 10 - PowerPoint PPT Presentation


  • 391 Views
  • Uploaded on

Chapter 10. Communication between modules, cohesion and coupling. Objectives. To introduce communication between modules To develop solution algorithms that pass parameters between modules To introduce cohesion as a measure of the internal strength of a module

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 10' - sharla


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 10

Chapter 10

Communication between modules, cohesion and coupling

objectives
Objectives
  • To introduce communication between modules
  • To develop solution algorithms that pass parameters between modules
  • To introduce cohesion as a measure of the internal strength of a module
  • To introduce coupling as a measure of the extent of information interchange between modules
slide3

10.1

Communication between modules

communication between modules
Communication between modules
  • Necessary to consider flow of information between modules
  • This flow of information is called ‘intermodule communication’ and can be accomplished by the scope of the variable
communication between modules5
Communication between modules
  • Scope of a variable
    • The portion of a program in which that variable has been defined and to which it can be referenced
    • Variables can be global where the scope of the variable is the whole program
    • Scope of the variable is simple the module which it is defined
communication between modules6
Communication between modules
  • Global data
    • Date that can be used by all the modules in a program
    • Every module in the program can access and change data
    • Lifetime of a global variable spans the execution of the whole program
communication between modules7
Communication between modules
  • Local data
    • Variable are defined within the submodule are called local variables
    • The scope of a local variable is simply the module in which it is defined
    • The lifetime of a local variable is limited to the execution of the single submodule in which it is defined
communication between modules8
Communication between modules
  • Side effects
    • Side effect is a form of a cross-communication of a module with other parts of a program,
    • Occurs when a subordinate module alters the value of a global variable inside a module
communication between modules9
Communication between modules
  • Passing parameters
    • Parameters are simply data items transferred from a calling module to its subordinate module at the time of calling
    • To pass parameters between modules, two things can happen:
      • The calling module must name the parameters that it wants to pass to the submodule
      • The submodule must be able to receive those parameters and return them to the calling module if required
communication between modules10
Communication between modules
  • Formal and actual parameters
    • Parameters names that appear when a submodule is defined are known as formal parameters
    • Variables and expressions that are passed to a submodule in a particular call are called actual parameters
communication between modules11
Communication between modules
  • Value and reference parameters
    • Parameters may have one of three function:
      • To pass information from a calling module to a subordinate module
      • To pass information from a subordinate module to its calling module
      • To fulfil a two-way communication role
communication between modules12
Communication between modules
  • Value and reference parameters
    • Value parameters
      • Value parameters pass a copy of the value of a parameter from one module to another
    • Reference parameters
      • Reference parameter pass the memory address of a parameter from one module to another
communication between modules13
Communication between modules
  • Hierarchy charts and parameters
    • Data parameters contain actual variables or data items that will be passed between modules
    • Status parameters act as a program flag and should contain just one of two values; true or false

Data parameters

Status parameters

slide14

10.3

Module cohesion

module cohesion
Module cohesion
  • Cohesion is a measure of the internal strength of a module
  • It indicates how closely the elements or the statements of a module are associated with each other
  • The more closely the elements of a module are associated with each other, the higher the cohesion of the module
module cohesion16
Module cohesion
  • Coincidental cohesion
    • Occurs when elements are collected into a module simply because they happen to fall together
    • Occur as a result of one of the following conditions:
      • Existing program may have been arbitrarily segmented into small modules
      • Existing program may have been arbitrarily subdivided to conform to a badly considered programming standard
      • A number of existing modules have been combined into one module
module cohesion17
Module cohesion
  • Logical cohesion
    • Logical cohesion occurs when the element of a module are grouped together according to a certain class of activity
    • The element falls into some general category because they all do the same kind of thing
module cohesion18
Module cohesion
  • Temporal cohesion
    • Occurs when the elements of a module are grouped together because they are related by time
    • Typical examples are initialisation and finalisation modules in which elements are placed together because they perform certain housekeeping functions at the beginning or end of a program
module cohesion19
Module cohesion
  • Procedural cohesion
    • Occurs when the elements of a module are related because they operate according to a particular procedure
    • The elements are executed in a particular sequence so that the objectives of the program are achieved
module cohesion20
Module cohesion
  • Communicational cohesion
    • Occurs when the element of a module are grouped together because they all operate on the same (central) piece of data
    • Are commonly found in business application because of the close relationship of a business program to the data it is processing
module cohesion21
Module cohesion
  • Sequential cohesion
    • Occurs when a module contains elements that depend on the processing of previous elements
    • Contain elements in which the output data from one element serves as input data to the next
slide22

10.4

Module coupling

module coupling
Module coupling
  • Coupling is a measure of the extent of information interchange between modules
  • Tight coupling implies large dependence on the structure of one module by another
  • Loose coupling is the opposite of tight coupling. Modules with loose coupling are more independent and easier to maintain
module coupling24

Global data structure

Module A

Module B

Module coupling
  • Common coupling
    • Occurs when modules reference the same global data structure
  • External coupling
    • Occurs when two or more modules access the same global data variable (similar to common coupling except that the global data is an elementary data item, rather than a data structure)

Global data variable

Module A

Module B

module coupling25

Module A

Module B

Module coupling
  • Control coupling
    • Occurs when a module passes another module a control variable that is intended to control the other module’s logic
  • Stamp coupling
    • Occurs when one module passes a non-global data structure to another module in the form of a parameter

Module A

Data structure

Module B

module coupling26
Module coupling
  • Data coupling
    • Occurs when a module passes a non-global data variable to another module (similar to stamp coupling except that the non-global data variable is an elementary data item, nota data structure)

Module A

Elementary data item

Module B

module coupling27
Module coupling
  • Summary of coupling levels
    • If the programming language allows it, try to uncouple each module from its surroundings by
      • Passing data to a subordinate module in the form of parameters, rather than using global data
      • Writing each subordinate module as a self-contained unit
summary
Summary
  • Introduced communication between modules and parameters.
  • Intermodule communication is the flow of information or data between modules.
  • Passing of parameters was introduced as a form of intermodule communication.
summary29
Summary
  • The differences between formal and actual parameters and value and reference parameters was explained.
  • Module cohesion and module coupling must be considered when designing modular programs.
  • Cohesion is a measure of the internal strength of a module.
  • Seven levels of cohesion were discussed.
summary30
Summary
  • Coupling is a measure of the extent of information interchange between modules.
  • Five levels of coupling were discussed.