12 Lecture
CS504
Midterm & Final Term Short Notes
Coupling and Cohesion
Coupling refers to the degree of interdependence between software components, while cohesion measures the relatedness of responsibilities within a component. Low coupling and high cohesion are desirable qualities in software design, promoting mo
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
Coupling in software design refers to: a) The degree of relatedness within a module b) The degree of interdependence between modules c) The degree of encapsulation within a class d) The degree of inheritance in an object-oriented system Solution: b) The degree of interdependence between modules Cohesion in software design refers to: a) The degree of relatedness within a module b) The degree of interdependence between modules c) The degree of encapsulation within a class d) The degree of inheritance in an object-oriented system Solution: a) The degree of relatedness within a module Which of the following is an example of low coupling? a) A module that relies on another module's internal implementation details b) A module that communicates with other modules through well-defined interfaces c) A module that shares global variables with other modules d) A module that directly modifies the internal state of another module Solution: b) A module that communicates with other modules through well-defined interfaces Which type of coupling is considered the most desirable? a) Content coupling b) Stamp coupling c) Control coupling d) Data coupling Solution: d) Data coupling Which type of cohesion is considered the most desirable? a) Coincidental cohesion b) Logical cohesion c) Sequential cohesion d) Functional cohesion Solution: d) Functional cohesion Which type of cohesion indicates that a module performs multiple unrelated functions? a) Coincidental cohesion b) Logical cohesion c) Sequential cohesion d) Functional cohesion Solution: a) Coincidental cohesion Which type of coupling indicates a strong dependency between modules? a) Loose coupling b) Tight coupling c) External coupling d) Control coupling Solution: b) Tight coupling Which type of cohesion indicates that a module performs functions in a specific order? a) Coincidental cohesion b) Logical cohesion c) Sequential cohesion d) Functional cohesion Solution: c) Sequential cohesion Which type of coupling indicates that one module directly modifies the internal state of another module? a) Message coupling b) Data coupling c) Content coupling d) Control coupling Solution: c) Content coupling Which type of cohesion indicates that a module groups together functions that operate on the same data? a) Coincidental cohesion b) Logical cohesion c) Sequential cohesion d) Functional cohesion Solution: b) Logical cohesion
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
Explain the concept of coupling in software design. Answer: Coupling refers to the degree of interdependence between software components. It measures how much one component relies on another. Low coupling is desirable as it promotes modularity, reusability, and flexibility. What is cohesion in software design? Answer: Cohesion refers to the degree of relatedness of responsibilities within a software component. It measures how closely the functions or operations in a module are aligned with a single purpose. High cohesion is desirable as it promotes maintainability and code organization. Discuss the difference between loose coupling and tight coupling. Answer: Loose coupling implies minimal dependencies between components, allowing them to be modified independently. In contrast, tight coupling indicates strong dependencies, where changes in one component may have a significant impact on others. Loose coupling promotes flexibility and ease of maintenance. How does low coupling contribute to software design? Answer: Low coupling reduces dependencies between components, making the system more modular, flexible, and maintainable. It allows for independent development and easier testing and facilitates the introduction of changes without causing cascading effects. What are the benefits of high cohesion in software design? Answer: High cohesion ensures that responsibilities within a component are closely related, making the component easier to understand, modify, and maintain. It promotes code reusability, reduces complexity, and improves overall system performance. Explain the concept of data coupling. Answer: Data coupling occurs when components share data through parameters or data structures. It indicates a low level of interdependence and is considered desirable as it reduces the impact of changes in one component on others. How can you improve cohesion in a software system? Answer: Cohesion can be improved by organizing functions and operations within modules based on their relatedness. Grouping related functions together and separating unrelated functions into separate modules can increase cohesion. Discuss the challenges of tight coupling in software design. Answer: Tight coupling increases the interdependence between components, making the system less flexible and more difficult to modify or maintain. Changes in one component may require modifications in multiple other components, increasing the risk of introducing errors. What is the relationship between coupling and dependency? Answer: Coupling refers to the degree of interdependence between components, while dependency represents a relationship where one component relies on another. Higher levels of coupling often result in stronger dependencies between components. How can you reduce coupling in a software system? Answer: Coupling can be reduced by using well-defined interfaces, applying design patterns like Dependency Injection, employing loose coupling principles like the Dependency Inversion Principle, and modularizing the system into cohesive components.