Assignment No.
4 - Software Engineering
Q1) Explain Coupling and Cohesion. Explain their types with examples.
Coupling: Coupling refers to the degree of interdependence between software modules. It measures how
closely connected two modules are. Low coupling means modules are independent, while high coupling
indicates strong dependency.
Types of Coupling:
1. Content Coupling – One module directly modifies the content of another.
2. Common Coupling – Multiple modules share global data.
3. Control Coupling – One module controls the flow of another by passing control information.
4. Stamp (Data-Structured) Coupling – Modules share a composite data structure.
5. Data Coupling – Modules share data through parameters.
6. Message Coupling – Modules communicate via message passing (common in OOP).
Cohesion: Cohesion measures how closely related the functions within a module are. High cohesion
indicates that a module performs one well-defined task.
Types of Cohesion:
1. Coincidental Cohesion – Unrelated functions grouped together.
2. Logical Cohesion – Similar functions selected by control flags.
3. Temporal Cohesion – Elements executed in the same time span.
4. Procedural Cohesion – Tasks performed in a specific sequence.
5. Communicational Cohesion – Functions operate on the same data set.
6. Sequential Cohesion – Output of one function is input to another.
7. Functional Cohesion – Module performs a single specific function.
Example:
Module A calculates student grades; Module B displays them. If they share only necessary data → low
coupling. Each performs a single task → high cohesion.
Q2) Explain the concept of Design.
Design in software engineering defines the architecture, components, interfaces, and data of a system. It
provides a blueprint for development and ensures the system meets requirements.
Concepts of Design:
1. Modularity – Breaking the system into smaller components.
2. Abstraction – Hiding unnecessary details.
3. Encapsulation – Binding data and behavior together.
4. Architecture – Defines system structure and component interaction.
5. Data Design – Organizes data storage and flow.
6. Interface Design – Defines how modules and users interact.
7. Procedural Design – Specifies algorithms for module operations.
Importance: Reduces complexity, improves maintainability, enhances scalability, and detects errors early.
Example: In an online shopping system, modules like User, Product, and Payment define design structure
and data flow.
Q3) What are Software Design Principles?
Software Design Principles are guidelines for building efficient, maintainable, and reliable software systems.
Main Principles:
1. Modularity – Divide system into independent modules.
2. Abstraction – Show only necessary details.
3. Encapsulation – Protect data using classes/methods.
4. Separation of Concerns – Each module should address a single concern.
5. Single Responsibility Principle – A class should have one reason to change.
6. Open/Closed Principle – Open for extension, closed for modification.
7. Liskov Substitution Principle – Derived classes must be substitutable for base classes.
8. Dependency Inversion – Depend on abstractions, not concrete classes.
9. DRY (Don’t Repeat Yourself) – Avoid code duplication.
10. KISS (Keep It Simple, Stupid) – Keep design simple and easy.
11. High Cohesion, Low Coupling – Independent, focused modules.
12. Information Hiding – Expose only necessary interfaces.
Conclusion: Following these principles ensures robust, flexible, and maintainable software systems.