Skip to main content

What is Coupling? What is Cohesion? Explain different types of Cohesion and Coupling with proper example.

Understanding Coupling and Cohesion in Software Engineering

What is Coupling?

  • Coupling refers to the degree of interdependence between modules or classes in a software system.
  • High coupling indicates strong dependencies, making changes difficult and increasing the risk of unintended consequences.
  • Low coupling promotes modularity, reusability, and maintainability.

Types of Coupling

  • Content Coupling: One module directly modifies data within another. Example: Module A directly changing variables inside Module B. This is extremely undesirable.
  • Common Coupling: Modules share global data. Example: Multiple modules accessing and modifying the same global variable. Difficult to manage and understand.
  • Control Coupling: One module controls the flow of execution in another using flags or parameters. Example: Module A passing a flag to Module B to dictate its behavior. Often avoidable through better design.
  • Stamp Coupling: Modules share a composite data structure, but only use a portion of it. Example: Passing a large object when only a small subset of its data is needed. Inefficient and leads to tight coupling.
  • Data Coupling: Modules communicate through passing data parameters. Example: Module A passing specific data values to Module B. The most desirable form of coupling.

What is Cohesion?

  • Cohesion refers to how closely related the functions within a single module or class are.
  • High cohesion implies that a module performs a single, well-defined task.
  • Low cohesion suggests that a module performs unrelated tasks, making it difficult to understand, maintain, and reuse.

Types of Cohesion

  • Coincidental Cohesion: Parts of a module have no logical relationship. Example: A module containing unrelated functions such as logging and database access. Weakest form of cohesion.
  • Logical Cohesion: A module performs multiple related functions, but each is invoked independently. Example: A module performing several validation operations. Slightly improved over coincidental, but still weak.
  • Temporal Cohesion: Functions within a module are grouped because they are executed at the same time. Example: A module containing functions that are all executed during system initialization. Better than logical, but still not ideal.
  • Procedural Cohesion: Functions are grouped because they are executed in a specific order. Example: A module with functions that perform steps in a particular process. Improves upon temporal.
  • Communicational Cohesion: Functions operate on the same data. Example: A module containing functions that process data from a single input file. Strong cohesion, good design.
  • Sequential Cohesion: Output of one function serves as input for another. Example: A module with functions where the output of one is the direct input of the next. Very strong cohesion.
  • Functional Cohesion: A module performs a single, well-defined function. Example: A module calculating the area of a circle. The strongest form of cohesion and ideal.

Popular Posts

Current Affairs 9 September 2025 | Nepal Protests, France PM Resigns, Windows 11 Update

Current Affairs – 09 September 2025 Major Highlights 1. Nepal Gen Z Protests Massive anti-government protests led by youth (Gen Z). PM K. P. Sharma Oli & ministers resigned and fled the country. Protesters burned Parliament & govt. buildings. Army deployed at airport & key locations. Trigger: Corruption charges & social media ban. 2. France Political Crisis PM François Bayrou resigned after losing confidence vote. President Macron now forced to appoint 3rd PM in just a year. Protests under slogan “Block Everything” intensify. 80,000+ police deployed across France to prevent unrest. 3. Windows 11 September 2025 Update Microsoft released Security & Feature Update. 9 key changes: Redesigned Recall app homepage. Seconds display in Notification Center. Grid view in Windows Search photos. Improved Widgets & Lock screen dashboard. AI agent in Settings app. Updated Windows Hello visuals. Modern Task Manager interface. Revamped File Explorer design. Windows Backup organi...

What are key featuers of python?.

Python for Data Compression: Key Features Readability and Simplicity Clear syntax, making code easy to write and understand. Reduced development time compared to other languages. Extensive Libraries `zlib`, `gzip`, `bz2`, for common compression algorithms. `lzma` for advanced LZMA compression. `zipfile` for managing compressed archives. Cross-Platform Compatibility Runs smoothly on various operating systems (Windows, macOS, Linux). Facilitates easy deployment of data compression solutions. Community Support and Resources Abundant online tutorials, documentation, and community forums. Easier troubleshooting and faster problem-solving. Integration with other tools Seamlessly integrates with other data science tools (NumPy, Pandas). Simplifies data preprocessing and post-processing steps.

Discuss basics of the motion field of rigid objects with necessary equations.

Understanding Rigid Object Motion in Computer Vision Defining the Motion Field The motion field describes the apparent movement of pixels in an image sequence. It's a 2D vector field, where each vector represents the velocity of a corresponding pixel. For rigid objects, all points move coherently, unlike non-rigid objects with independent movements. Motion of a Rigid Object: Translation Pure translation involves only a change in position. Let `(x, y)` be the pixel coordinates and `(u, v)` be the displacement vector. Then, `u = t_x` and `v = t_y`, where `t_x` and `t_y` are the components of the translation vector. Motion of a Rigid Object: Rotation Pure rotation around a point (e.g., the object's center) is described using a rotation matrix. The rotation matrix R is a 2x2 matrix dependent on the rotation angle θ. The rotation equations are: `x' = x cosθ - y sinθ` and `y' = x sinθ + y cosθ`. `x', y'` are the rotated coordinates. Combi...

Explain different classes of attacks

Demystifying Cyber Attacks: A Classification for Enhanced Security Passive Attacks Eavesdropping on network traffic. Traffic analysis to infer communication patterns. Monitoring user activity without interaction. Active Attacks Modification of data in transit. Denial-of-service attacks flooding systems. Impersonation through forged packets. Man-in-the-middle attacks intercepting communication. Attacks Based on Target Web Application Attacks (SQL Injection, XSS). Network Attacks (ARP Spoofing, DDoS). Host-Based Attacks (Malware infections, privilege escalation). Data Attacks (Data breaches, data exfiltration). Attacks Based on Methodology Exploiting vulnerabilities in software/hardware. Social engineering (phishing, baiting). Brute-force attacks (password guessing). Insider threats (malicious employees). Attacks Based on Intent Data theft for financial gain or espionage. System disruption for vandalism or protest. Data manipulation to defraud or manipulate....

What is meant by “Scope” and “Rigor” of a project? Briefly discuss the factors that influence Rigor during agile project development.

Agile Development & UI/UX: Balancing Scope and Rigor What is Project Scope? Defines the project's boundaries. Includes features, functionalities, and deliverables. Outlines what will be created and what will not. Crucial for managing expectations and resources. What is Project Rigor? The level of precision, formality, and adherence to process. Impacts quality, consistency, and predictability. Higher rigor often means more documentation and testing. Lower rigor allows for greater flexibility and speed. Factors Influencing Rigor in Agile Development Team Expertise: Experienced teams might need less formal processes. Project Complexity: Complex projects demand higher rigor. Client Involvement: High client involvement may necessitate more defined processes. Regulatory Requirements: Compliance needs increase rigor. Risk Tolerance: Higher risk tolerance can lead to lower rigor. Time Constraints: Tight deadlines can impact the level of rigor. UI/UX Design Complexi...