Modules Flashcards

1
Q

Why abstraction is an advantage

A
  • we know what it does, we don’t worry about how it works
  • makes it easier for several members of a team to work on the same project
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What properties should modules have?

A
  • High cohesion - the elements of each module should be closely related to one another
  • Low coupling - should be independent as possible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is coincidental cohesion?

A

A function that performs unrelated operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is logical cohesion?

A

Performs one of several operations based upon a control flag parameter. Does 1 or 5 different things based on a control parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is procedural cohesion?

A

performs operations in a specific order, but the operations do not share any data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is temporal cohesion?

A

performs several operations which are related only because they must be performed at the same time.

  • initialize an array
  • initialize values in array
  • prints instructions

fix: have them call seperate functions that do each operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is communicational cohesion?

A

performs operations on the same data but are not otherwise related.

  • get name and phone number
  • verify age and id

considered acceptable if necessary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Sequential cohesion

A

function with operations that must be performed in a specific order, with the output of one operation being the input of the next.

Example:

  1. Inputs the number of students
  2. Inputs the final exam grade for each student
  3. calculates the min, max and average final exam grade
  4. Displays the student grades
  5. Displays the min, max and the average grade
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is functional cohesion

A

idea case

performs only one operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Module Cohesion?

A
  • a .c source file which contains several function
  • how the data and functions within the module are related
  • should contain data and a group of functions that clearly belong together.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

List the function couplings

A

Bad

  • Content coupling - one function uses code inside another function (via goto)
  • Control Coupling - one function passes a parameter to another to tell the second function what to do (logical cohesion)

Acceptable

  • Common coupling - two functions use the same global data
  • Stamp coupling - function passes a struct to another function (second function must use most of the data in the struct)
  • Data coupling - only passes primitive data another function need <– most desirable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly