Quiz 7: From Modules to Objects

Computing

Definition of modularity: First definition of module: Module is a collection of more than one adjacent program statements having a "name" that can be invoked by some other parts of system, and it prefers to have its own unique collection of variable names. Second definition of module: Module contains the single block of code which can be invoked with the "procedure", "function", or "method". It looks like a broad concept and all functions and procedures can be compiled in both internally or externally. Consider the following examples: Let us take programming language "Java". "Java" is a programming language which contains the "classes" and "method". • Classes contain block of code for execution. So, "Java" supports the second definition of module. • Method contains the set of statements or block of code to invoke the method. So, "Java" supports both the definitions such as "first" and "second" definition of module. Let us take programming language "C". "C" is a programming language which contains the "functions/methods" and "files". • Functions/methods contain the block of code or collection of program statements for execution. So, "C" language supports both the definitions such as "first" and "second" definition of module. • Files contain block of input or output statements for execution. So, "C" supports the "second" definition of module. Let us take programming language "C++". "C++" is a programming language which contains the "functions/methods" and "files". • Functions/methods contain the block of code or collection of program statements for execution. So, "C++" language supports both the definitions such as "first" and "second" definition of module. • Class contain block of code for execution. So, "C++" supports the "second" definition of module.

Cohesion refers to the relationship within the elements of a module. The respective cohesion for each module is addressed as follows and also determined how the module performs its operations. The interrelationship between the module and cohesion is identified as follows: • editProfitAndTaxRecord: This module comes under Functional cohesion because it contributes a single task which means it executes only one task related to the problem. Here it can only read the record. • editProfitRecordAndTaxRecord: This module comes under Procedural cohesion because it carry out a sequence of operations. It can write the record, read the record and edit the record. • readDeliveryRecordAndCheckSalaryPayrnents: This module comes under coincidental cohesion because, elements in the module has no meaningful relationship which means that the activities are unrelated. It can read different types of operations. • ComputeTheOptimalCostUsingAksen'sAlgorithm: This module comes under functional cohesion because the elements in the module has only one task. • measureVaporPressureAndSoundAlarrnifNecessary: This module comes under Procedural cohesion because, the elements in the module has sequence of operations.

Cohesion refers to the relationship within the elements of a module. Informational cohesion strongly supports the modules to reuse. The following are the ways to determine the reusability of the modules: 1. To reuse the modules, make sure that modules have high cohesion, and low coupling when compare with other modules. 2. Information hiding techniques are essential for module reusability. 3. Object-oriented paradigm usage also aids in reusability.

There is no answer for this question