Which is correct?

Give:

Class Employee {

public int checkEmail() {/* . . . */}

public void sendEmail (String email) {/* . . . */}

public Boolean validDateEmail(){/* . . . */}

public void printLetter (String letter) {/* . . . */}

}

Which is correct?

Give:

Class Employee {

public int checkEmail() {/* . . . */}

public void sendEmail (String email) {/* . . . */}

public Boolean validDateEmail(){/* . . . */}

public void printLetter (String letter) {/* . . . */}

}

Which is correct?

A.
Employee takes advantage of composition.

B.
Employee “has-an” Email.

C.
Employee “is-a” LetterPrinter.

D.
Employee has low cohesion.

Explanation:
The relationship between Employee and e-mail is poorly implemented here.
There is low cohesion.

Note:
Low cohesion is associated with undesirable traits such as being difficult to maintain, difficult to test, difficult to reuse, and even difficult to understand.

Cohesion is decreased if:
The functionalities embedded in a class, accessed through its methods, have little in common. Methods carry out many varied activities, often using coarsely-grained or unrelated sets of data. Disadvantages of low cohesion (or”weak cohesion”) are:
Increased difficulty in understanding modules.
Increased difficulty in maintaining a system, because logical changes in the domain affect multiple modules, and because changes in one module require changes in related modules.
Increased difficulty in reusing a module because most applications won’t need the random set of operations provided by a module.

Reference:Cohesion (computer science)



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Marian

Marian

I guess either the correct option or some condition is missing here

Jav

Jav

Employee has low cohesion